aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Šmerkl <46304018+SveterCZE@users.noreply.github.com>2021-05-07 21:03:33 +0200
committerPetr Šmerkl <46304018+SveterCZE@users.noreply.github.com>2021-05-07 21:03:33 +0200
commita831afb60cfaed5ec342fab1e4a7eb83feb9c4f7 (patch)
tree6918454a9922d7c08bf67a69960a499a6daf208b
parentba27366d9f411af56a594ccaee9895434d393ef5 (diff)
downloadjustice-a831afb60cfaed5ec342fab1e4a7eb83feb9c4f7.tar.gz
Add search by additional properies
-rw-r--r--forms.py8
-rw-r--r--main.py34
-rw-r--r--templates/search_form.html18
3 files changed, 59 insertions, 1 deletions
diff --git a/forms.py b/forms.py
index 9cbad2f..73e576a 100644
--- a/forms.py
+++ b/forms.py
@@ -30,6 +30,14 @@ class JusticeSearchForm(Form):
ulice_search = StringField(u'Ulice:')
ulice_search_selection = SelectField('', choices=search_options)
ulice_search_actual = SelectField('', choices=actual_options)
+
+ cp_search = StringField(u'Číslo popisné:')
+ cp_search_selection = SelectField('', choices=search_options)
+ cp_search_actual = SelectField('', choices=actual_options)
+
+ co_search = StringField(u'Číslo orientační:')
+ co_search_selection = SelectField('', choices=search_options)
+ co_search_actual = SelectField('', choices=actual_options)
oddil_search = StringField(u'Oddíl:')
oddil_search_selection = SelectField('', choices=search_options)
diff --git a/main.py b/main.py
index ee090d3..608e50f 100644
--- a/main.py
+++ b/main.py
@@ -178,6 +178,14 @@ def search_results(search):
ulice_search_method = search.ulice_search_selection.data
ulice_actual_or_full = search.ulice_search_actual.data
+ co = search.co_search.data
+ co_search_method = search.co_search_selection.data
+ co_actual_or_full = search.co_search_actual.data
+
+ cp = search.cp_search.data
+ cp_search_method = search.cp_search_selection.data
+ cp_actual_or_full = search.cp_search_actual.data
+
pravni_forma = search.pravni_forma_search.data
pravni_forma_actual_or_full = search.pravni_forma_actual.data
@@ -263,7 +271,31 @@ def search_results(search):
qry = qry.filter(Adresy_v2.ulice.like(f'{ulice}%'))
elif ulice_search_method == "text_exact":
qry = qry.filter(Adresy_v2.ulice == ulice)
-
+
+ if cp:
+ qry = qry.join(Sidlo_Association, Company.sidlo_text)
+ if cp_actual_or_full == "actual_results":
+ qry = qry.filter(Sidlo_Association.vymaz_datum == 0)
+ qry = qry.join(Adresy_v2, Sidlo_Association.sidlo_text)
+ if cp_search_method == "text_anywhere":
+ qry = qry.filter(Adresy_v2.cisloPo.contains(cp))
+ elif cp_search_method == "text_beginning":
+ qry = qry.filter(Adresy_v2.cisloPo.like(f'{cp}%'))
+ elif cp_search_method == "text_exact":
+ qry = qry.filter(Adresy_v2.cisloPo == cp)
+
+ if co:
+ qry = qry.join(Sidlo_Association, Company.sidlo_text)
+ if co_actual_or_full == "actual_results":
+ qry = qry.filter(Sidlo_Association.vymaz_datum == 0)
+ qry = qry.join(Adresy_v2, Sidlo_Association.sidlo_text)
+ if co_search_method == "text_anywhere":
+ qry = qry.filter(Adresy_v2.cisloOr.contains(co))
+ elif co_search_method == "text_beginning":
+ qry = qry.filter(Adresy_v2.cisloOr.like(f'{co}%'))
+ elif co_search_method == "text_exact":
+ qry = qry.filter(Adresy_v2.cisloOr == co)
+
if pravni_forma:
qry = qry.join(Pravni_Forma_Association_v2, Company.pravni_forma_text)
if pravni_forma_actual_or_full == "actual_results":
diff --git a/templates/search_form.html b/templates/search_form.html
index 14c387d..f4fc7a9 100644
--- a/templates/search_form.html
+++ b/templates/search_form.html
@@ -57,6 +57,24 @@
<div class="row g-2">
<div class="col-sm-3">
+ {{ form.cp_search.label }}
+ </div>
+ <div class="col-sm">
+ {{ form.cp_search()|safe }} {{ form.cp_search_selection }} {{ form.cp_search_actual }}
+ </div>
+ </div>
+
+ <div class="row g-2">
+ <div class="col-sm-3">
+ {{ form.co_search.label }}
+ </div>
+ <div class="col-sm">
+ {{ form.co_search()|safe }} {{ form.co_search_selection }} {{ form.co_search_actual }}
+ </div>
+ </div>
+
+ <div class="row g-2">
+ <div class="col-sm-3">
{{ form.oddil_search.label }}
</div>
<div class="col-sm">