diff options
author | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-03-14 01:25:12 +0100 |
---|---|---|
committer | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-03-14 01:25:12 +0100 |
commit | b0176b943aa21db7c0dd8305fc19d2011c1a2d9f (patch) | |
tree | 1397cdcd317bdec846c0a199ee739f26371708e2 /main.py | |
parent | 3c1fd0285ebff35428ad0512d3e371980642270e (diff) | |
download | justice-b0176b943aa21db7c0dd8305fc19d2011c1a2d9f.tar.gz |
multiple tweaks and new features
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 71 |
1 files changed, 53 insertions, 18 deletions
@@ -7,7 +7,7 @@ from flask import flash, render_template, request, redirect from models import Company, Obce, Ulice, Insolvency_Events, Predmet_Podnikani, Predmety_Podnikani_Association, Predmet_Cinnosti, Predmety_Cinnosti_Association from models import Zakladni_Kapital, Akcie, Nazvy, Sidlo, Sidlo_Association, Pravni_Forma_Association_v2, Pravni_Formy, Statutarni_Organ_Association, Statutarni_Organy, Pocty_Clenu_Organu from models import Zpusob_Jednani_Association, Zpusob_Jednani, Statutarni_Organ_Clen_Association, Fyzicka_Osoba, Spolecnici_Association, Podily_Association, Druhy_Podilu, Pravnicka_Osoba -from models import Prokurista_Association, Jediny_Akcionar_Association, Prokura_Common_Text_Association +from models import Prokurista_Association, Jediny_Akcionar_Association, Prokura_Common_Text_Association, Soudni_Zapisy from tables import Results init_db() @@ -24,28 +24,41 @@ def index(): @app.route('/results') def search_results(search): results = [] + ico = search.ico_search.data ico_search_method = search.ico_search_selection.data + nazev = search.nazev_subjektu.data nazev_search_method = search.nazev_subjektu_selection.data + nazev_actual_or_full = search.nazev_search_actual.data + oddil = search.oddil_search.data oddil_search_method = search.oddil_search_selection.data + oddil_actual_or_full = search.oddil_search_actual.data + vlozka = search.vlozka_search.data vlozka_search_method = search.vlozka_search_selection.data + vlozka_actual_or_full = search.vlozka_search_actual.data + obec = search.obec_search.data obec_search_method = search.obec_search_selection.data + ulice = search.ulice_search.data ulice_search_method = search.ulice_search_selection.data + pravni_forma = search.pravni_forma_search.data + pravni_forma_actual_or_full = search.pravni_forma_actual.data + soud = search.soud_search.data + soud_actual_or_full = search.soud_search_actual.data + + insolvent_only = search.insolvent_only_search.data + zapsano_od = search.zapis_od.data zapsano_do = search.zapis_do.data + qry = Company.query - # if insolvent_only == False: - # qry = Company.query.join(Obce, Company.obec).join(Ulice, Company.ulice).join(Pravni_Forma, Company.pravni_forma).join(Insolvency_Events, isouter=True) - # else: - # qry = Company.query.join(Obce, Company.obec).join(Ulice, Company.ulice).join(Pravni_Forma, Company.pravni_forma).join(Insolvency_Events, Company.insolvence) if ico: if ico_search_method == "text_anywhere": qry = qry.filter(Company.ico.contains(ico)) @@ -53,30 +66,40 @@ def search_results(search): qry = qry.filter(Company.ico.like(f'{ico}%')) elif ico_search_method == "text_exact": qry = qry.filter(Company.ico == ico) + if nazev: + qry = qry.join(Nazvy, Company.obchodni_firma) + if nazev_actual_or_full == "actual_results": + qry = qry.filter(Nazvy.vymaz_datum == 0) if nazev_search_method == "text_anywhere": - qry = qry.filter(Company.nazev.contains(nazev)) + qry = qry.filter(Nazvy.nazev_text.contains(nazev)) elif nazev_search_method == "text_beginning": - qry = qry.filter(Company.nazev.like(f'{nazev}%')) + qry = qry.filter(Nazvy.nazev_text.like(f'{nazev}%')) elif nazev_search_method == "text_exact": - qry = qry.filter(Company.nazev == nazev) + qry = qry.filter(Nazvy.nazev_text == nazev) + if oddil: + qry = qry.join(Soudni_Zapisy, Company.soudni_zapis) + if oddil_actual_or_full == "actual_results": + qry = qry.filter(Soudni_Zapisy.vymaz_datum == 0) if oddil_search_method == "text_anywhere": qry = qry.filter(Company.oddil.contains(oddil)) elif oddil_search_method == "text_beginning": qry = qry.filter(Company.oddil.like(f'{oddil}%')) elif oddil_search_method == "text_exact": qry = qry.filter(Company.oddil == oddil) - # qry = qry.filter(Company.oddil.contains(oddil)) + if vlozka: + qry = qry.join(Soudni_Zapisy, Company.soudni_zapis) + if vlozka_actual_or_full == "actual_results": + qry = qry.filter(Soudni_Zapisy.vymaz_datum == 0) if vlozka_search_method == "text_anywhere": - qry = qry.filter(Company.vlozka.contains(vlozka)) + qry = qry.filter(Soudni_Zapisy.vlozka.contains(vlozka)) elif vlozka_search_method == "text_beginning": - qry = qry.filter(Company.vlozka.like(f'{vlozka}%')) + qry = qry.filter(Soudni_Zapisy.vlozka.like(f'{vlozka}%')) elif vlozka_search_method == "text_exact": - qry = qry.filter(Company.vlozka == vlozka) + qry = qry.filter(Soudni_Zapisy.vlozka == vlozka) - # qry = qry.filter(Company.vlozka.contains(vlozka)) if obec: qry = qry.join(Obce, Company.obec) if obec_search_method == "text_anywhere": @@ -85,7 +108,7 @@ def search_results(search): qry = qry.filter(Obce.obec_jmeno.like(f'{obec}%')) elif obec_search_method == "text_exact": qry = qry.filter(Obce.obec_jmeno == obec) - # qry = qry.filter(Obce.obec_jmeno.contains(obec)) + if ulice: qry = qry.join(Ulice, Company.ulice) if ulice_search_method == "text_anywhere": @@ -94,12 +117,24 @@ def search_results(search): qry = qry.filter(Ulice.ulice_jmeno.like(f'{ulice}%')) elif ulice_search_method == "text_exact": qry = qry.filter(Ulice.ulice_jmeno == ulice) - # qry = qry.filter(Ulice.ulice_jmeno.contains(ulice)) + if pravni_forma: - qry = qry.join(Pravni_Forma, Company.pravni_forma) - qry = qry.filter(Pravni_Forma.pravni_forma.contains(pravni_forma)) + qry = qry.join(Pravni_Forma_Association_v2, Company.pravni_forma_text) + if pravni_forma_actual_or_full == "actual_results": + qry = qry.filter(Pravni_Forma_Association_v2.vymaz_datum == 0) + qry = qry.join(Pravni_Formy, Pravni_Forma_Association_v2.pravni_forma_text) + qry = qry.filter(Pravni_Formy.pravni_forma == pravni_forma) + if soud: - qry = qry.filter(Company.soud.contains(soud)) + qry = qry.join(Soudni_Zapisy, Company.soudni_zapis) + if soud_actual_or_full == "actual_results": + qry = qry.filter(Soudni_Zapisy.vymaz_datum == 0) + qry = qry.filter(Soudni_Zapisy.soud == soud) + + # qry = qry.filter(Company.soud.contains(soud)) + + + if zapsano_od: qry = qry.filter(Company.zapis >= zapsano_od) if zapsano_do: |