Search in variants. Closes #2

This commit is contained in:
Stephane Bortzmeyer 2023-10-01 11:40:28 +02:00
parent 9bc5b62ca2
commit e2d93bdd82
2 changed files with 6 additions and 0 deletions

View File

@ -71,6 +71,9 @@ def application(environ, start_response):
elif form["what"] == "region":
sql = "SELECT code,added,comments FROM Regions WHERE code = %s"
term = form["string"].upper()
elif form["what"] == "variant":
sql = "SELECT code,added,comments FROM Variants WHERE code = %s"
term = form["string"].lower()
else:
status = "400 Invalid request"
msg = "Unknown search category \"%s\"\r\n" % form["what"]
@ -100,6 +103,8 @@ def application(environ, start_response):
sql = "SELECT Scripts.code, Descriptions.description FROM Scripts,Descriptions_Scripts,Descriptions WHERE Descriptions_Scripts.description = Descriptions.id AND Descriptions_Scripts.script = Scripts.code AND position(%s in lower(Descriptions.description)) > 0;"
elif form["what"] == "region":
sql = "SELECT Regions.code, Descriptions.description FROM Regions,Descriptions_Regions,Descriptions WHERE Descriptions_Regions.description = Descriptions.id AND Descriptions_Regions.region = Regions.code AND position(%s in lower(Descriptions.description)) > 0;"
elif form["what"] == "variant":
sql = "SELECT Variants.code, Descriptions.description FROM Variants,Descriptions_Variants,Descriptions WHERE Descriptions_Variants.description = Descriptions.id AND Descriptions_Variants.variant = Variants.code AND position(%s in lower(Descriptions.description)) > 0;"
cursor.execute(sql, (form["string"], ))
found = False
with tag("h1"):

View File

@ -7,6 +7,7 @@
<option value="language">Languages</option>
<option value="script">Scripts</option>
<option value="region">Regions</option>
<option value="variant">Variants</option>
</select></p>
<p><input type="submit" value="Search"/></p>
</form>