diff options
author | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-04-04 20:45:11 +0200 |
---|---|---|
committer | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-04-04 20:45:11 +0200 |
commit | 2d8d74a12ef5c3aadd9981e2750c7dd75f5e23af (patch) | |
tree | 8438037a5f01e3924d480f211b5817e7ba65398b | |
parent | a0c18133e49455b70762bd1ee08ab8408ff03401 (diff) | |
download | justice-2d8d74a12ef5c3aadd9981e2750c7dd75f5e23af.tar.gz |
minor clean-up changes
-rw-r--r-- | main.py | 85 | ||||
-rw-r--r-- | models.py | 2 | ||||
-rw-r--r-- | templates/results2.html | 2 | ||||
-rw-r--r-- | update_db.py | 11 |
4 files changed, 2 insertions, 98 deletions
@@ -1,9 +1,7 @@ -# test.py from app import app from db_setup import init_db, db_session from forms import JusticeSearchForm, CompanyForm from flask import flash, render_template, request, redirect -# from models import Company, Soud from models import Company, Insolvency_Events, Konkurz_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 @@ -147,8 +145,6 @@ def search_results(search): 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) @@ -156,12 +152,6 @@ def search_results(search): qry = qry.filter(Company.zapis <= zapsano_do) results = qry.all() - # else: - # qry = db_session.query(Company) - # results = qry.all() - # else: - # qry = db_session.query(Company) - # results = qry.all() if not results: flash('No results found!') @@ -170,43 +160,8 @@ def search_results(search): else: table = Results(results) table.border = True - # return render_template('results.html', table=table) return render_template("results2.html", results=results, form=search, zapsano_od=zapsano_od, zapsano_do=zapsano_do) -def search_results_BACKUP(search): - results = [] - search_string = search.data['search'] - - if search_string: - # if search.data['select'] == 'soud': - # qry = db_session.query(Company, Soud).filter( - # Soud.id==Company.soud_id).filter( - # Soud.name.contains(search_string)) - # results = [item[0] for item in qry.all()] - if search.data['select'] == 'nazev': - qry = db_session.query(Company).filter( - Company.nazev.contains(search_string)) - results = qry.all() - elif search.data['select'] == 'ico': - qry = db_session.query(Company).filter( - Company.ico.contains(search_string)) - results = qry.all() - else: - qry = db_session.query(Company) - results = qry.all() - else: - qry = db_session.query(Company) - results = qry.all() - - if not results: - flash('No results found!') - return redirect('/') - - else: - table = Results(results) - table.border = True - return render_template('results.html', table=table) - @app.route("/<int:ico>", methods=['GET', 'POST']) def extract(ico): qry = Company.query @@ -221,45 +176,5 @@ def extract_actual(ico): results = qry.all() return render_template("extract-actual.html", ico = ico, results = results) -@app.route('/new_company', methods=['GET', 'POST']) -def new_company(): - """ - Add a new company - """ - form = CompanyForm(request.form) - - if request.method == 'POST' and form.validate(): - # save the album - company = Company() - save_changes(company, form, new=True) - flash('Company created successfully!') - return redirect('/') - return render_template('new_company.html', form=form) - -def save_changes(company, form, new=False): - """ - Save the changes to the database - """ - # Get data from form and assign it to the correct attributes - # of the SQLAlchemy table object - # soud = Soud() - # soud.name = form.soud.data - - # company.soud = soud - company.soud = form.soud.data - company.ico = form.ico.data - company.nazev = form.nazev.data - company.sidlo = form.sidlo.data - company.zapis = form.zapis.data - company.oddil = form.oddil.data - company.vlozka = form.vlozka.data - company.vymaz = form.vymaz.data - if new: - # Add the new album to the database - db_session.add(company) - # commit the data to the database - db_session.commit() - - if __name__ == '__main__': app.run()
\ No newline at end of file @@ -306,7 +306,7 @@ class Adresy_v2(db.Model): return self.komplet_adresa if self.ulice != "0": joined_address += self.ulice + " " - if self.cisloText != "0": + if self.cisloText != "0" and self.cisloText != None: joined_address += self.cisloText + ", " if self.cisloPo != 0: if self.ulice == "0": diff --git a/templates/results2.html b/templates/results2.html index edef06a..84b8326 100644 --- a/templates/results2.html +++ b/templates/results2.html @@ -61,7 +61,7 @@ </tr> <tr> <td>Sídlo:</td> - <td>{{ current_seat[0].sidlo_text }} </td> + <td>{% if current_seat|length != 0 %}{{ current_seat[0].sidlo_text }}{% else %}znepřístupněno podle § 25 odst. 2 zákona č. 304/2013 Sb.{% endif %}</td> <td><a href="/{{ row.ico }}">Úplný výpis</a></td> <td><a href="/{{ row.ico }}-actual">Aktuální výpis</a></td> </tr> diff --git a/update_db.py b/update_db.py index 1dcb09a..3a9fba0 100644 --- a/update_db.py +++ b/update_db.py @@ -81,10 +81,8 @@ def insert_relation_information(c, elem, primary_sql_key, ancillary_table_key): def find_other_properties(c, ICO, element, conn, primary_sql_key): try: - # my_iter = element.iter("udaje") my_iter = element.findall("udaje") for elem in my_iter: - # my_iter2 = elem.iter("Udaj") my_iter2 = elem.findall("Udaj") for elem2 in my_iter2: udajTyp_name = str(get_prop(elem2, ".//udajTyp/kod")) @@ -189,7 +187,6 @@ def find_statutar(c, ICO, elem2, conn, primary_sql_key, element): elif udajTyp_name == "STATUTARNI_ORGAN_CLEN": find_clen_statut_org(c, ICO, elem, conn, relationship_table_key, element) else: - # print(str(get_prop(elem, "udajTyp/kod"))) pass except Exception as f: print(f) @@ -203,13 +200,11 @@ def find_spolecnik(c, ICO, elem2, conn, primary_sql_key, element): vymaz_datum = str(get_prop(elem, "vymazDatum")) spolecnik_typ = str(get_prop(elem, "hodnotaUdaje/typ")) # TODO Chech these conditions, they sometimes cause a person not being stored (IC 27650081) - # if spolecnik_type == "SPOLECNIK_OSOBA" and spolecnik_oznaceni == "Společník": if spolecnik_type == "SPOLECNIK_OSOBA" and spolecnik_typ == "OSOBA": # TODO alternativy pro None, Spolecny podil a Uvolneny podil text_spolecnik = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value")) nazev = str(get_prop(elem, "osoba/nazev")) # TODO Fix - make reference to type of person - some foreign persons have no ico or regCo, so they are assigned a number for a natural person - # if spol_ico == "0" and regCislo == "0": if nazev == "0": # I probably do not need the primary sql key spolecnik_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element) @@ -323,7 +318,6 @@ def find_dozorci_rada(c, ICO, elem2, conn, primary_sql_key, element): find_pocet_clenu_dr(c, ICO, elem, conn, relationship_table_key, element) elif udajTyp_name == "DOZORCI_RADA_CLEN": find_clen_dr(c, ICO, elem, conn, relationship_table_key, element) - # find_clen_dr(c, ICO, elem, conn, relationship_table_key, element) except Exception as f: print(f) @@ -337,7 +331,6 @@ def find_prokura(c, ICO, elem2, conn, primary_sql_key, element): vymaz_datum = str(get_prop(elem, "vymazDatum")) text_prokurista = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value")) prokurista_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element) - # adresa_id = find_and_store_address(c, elem) adresa_id = sidlo3(c, elem, primary_sql_key) c.execute("INSERT INTO prokuriste (company_id, zapis_datum, vymaz_datum, prokurista_fo_id, adresa_id, text_prokurista) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, prokurista_fo_id, adresa_id, text_prokurista,)) else: @@ -360,12 +353,10 @@ def find_sole_shareholder(c, ICO, elem2, conn, primary_sql_key, element): spol_ico = str(get_prop(elem, "osoba/ico")) regCislo = str(get_prop(elem, "osoba/regCislo")) akcionar_po_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo) - # adresa_id = find_and_store_address(c, elem) adresa_id = sidlo3(c, elem, primary_sql_key) c.execute("INSERT into jediny_akcionar (company_id, zapis_datum, vymaz_datum, text_akcionar, akcionar_po_id, adresa_id) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, text_akcionar, akcionar_po_id, adresa_id,)) elif typ_akcionar == "F": akcionar_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element) - # adresa_id = find_and_store_address(c, elem) adresa_id = sidlo3(c, elem, primary_sql_key) c.execute("INSERT into jediny_akcionar (company_id, zapis_datum, vymaz_datum, text_akcionar, akcionar_fo_id, adresa_id) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, text_akcionar, akcionar_fo_id, adresa_id,)) except Exception as f: @@ -426,7 +417,6 @@ def sidlo3(c, elem, primary_sql_key): else: address_key = sidlo_id[0] return address_key - # print(address_key) except Exception as e: print(e) @@ -489,7 +479,6 @@ def find_clen_statut_org(c, ICO, elem, conn, relationship_table_key, element): clenstviDo = str(get_prop(elem, "clenstviDo")) if typ_osoby == "AngazmaFyzicke": osoba_id = find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element) - # adresa_id = find_and_store_address(c, elem) adresa_id = sidlo3(c, elem, relationship_table_key) c.execute("INSERT into statutarni_organ_clen_relation (statutarni_organ_id, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,)) except Exception as f: |