From e2d93bdd82c182cf5a80b5d6b8584888ebb4b605 Mon Sep 17 00:00:00 2001 From: Stephane Bortzmeyer Date: Sun, 1 Oct 2023 11:40:28 +0200 Subject: [PATCH] Search in variants. Closes #2 --- search.py | 5 +++++ search.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/search.py b/search.py index d4833a1..84ceb19 100755 --- a/search.py +++ b/search.py @@ -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"): diff --git a/search.xml b/search.xml index 9d19664..f8d3ad4 100644 --- a/search.xml +++ b/search.xml @@ -7,6 +7,7 @@ +