diff options
author | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-02-11 21:42:14 +0100 |
---|---|---|
committer | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-02-11 21:42:14 +0100 |
commit | bc6b5bdecde3fa4706df6df847c7e07af30229f6 (patch) | |
tree | c0d266a16a1fbce23583cf0d708aa290b104dd5e | |
parent | 83b0b2e72d775279ba8ac8bc218ba76128fca1c9 (diff) | |
download | justice-bc6b5bdecde3fa4706df6df847c7e07af30229f6.tar.gz |
adding an option for an actual extract
-rw-r--r-- | .gitignore | 99 | ||||
-rw-r--r-- | forms.py | 3 | ||||
-rw-r--r-- | justice_main.py | 8 | ||||
-rw-r--r-- | main.py | 14 | ||||
-rw-r--r-- | models.py | 18 | ||||
-rw-r--r-- | templates/extract-actual.html | 165 | ||||
-rw-r--r-- | templates/results2.html | 2 |
7 files changed, 294 insertions, 15 deletions
@@ -156,3 +156,102 @@ pyvenv.cfg justice-testing.db as-actual-ostrava-2021.xml as-actual-ostrava-2021-test.xml +Scripts/_asyncio.pyd +Scripts/_bz2.pyd +Scripts/_ctypes_test.pyd +Scripts/_ctypes.pyd +Scripts/_decimal.pyd +Scripts/_elementtree.pyd +Scripts/_hashlib.pyd +Scripts/_lzma.pyd +Scripts/_msi.pyd +Scripts/_multiprocessing.pyd +Scripts/_overlapped.pyd +Scripts/_queue.pyd +Scripts/_socket.pyd +Scripts/_sqlite3.pyd +Scripts/_ssl.pyd +Scripts/_testbuffer.pyd +Scripts/_testcapi.pyd +Scripts/_testconsole.pyd +Scripts/_testimportmultiple.pyd +Scripts/_testinternalcapi.pyd +Scripts/_testmultiphase.pyd +Scripts/_tkinter.pyd +Scripts/activate +Scripts/activate_this.py +Scripts/activate.bat +Scripts/activate.fish +Scripts/activate.ps1 +Scripts/activate.xsh +Scripts/api-ms-win-core-console-l1-1-0.dll +Scripts/api-ms-win-core-datetime-l1-1-0.dll +Scripts/api-ms-win-core-debug-l1-1-0.dll +Scripts/api-ms-win-core-errorhandling-l1-1-0.dll +Scripts/api-ms-win-core-file-l1-1-0.dll +Scripts/api-ms-win-core-file-l1-2-0.dll +Scripts/api-ms-win-core-file-l2-1-0.dll +Scripts/api-ms-win-core-handle-l1-1-0.dll +Scripts/api-ms-win-core-heap-l1-1-0.dll +Scripts/api-ms-win-core-interlocked-l1-1-0.dll +Scripts/api-ms-win-core-libraryloader-l1-1-0.dll +Scripts/api-ms-win-core-localization-l1-2-0.dll +Scripts/api-ms-win-core-memory-l1-1-0.dll +Scripts/api-ms-win-core-namedpipe-l1-1-0.dll +Scripts/api-ms-win-core-processenvironment-l1-1-0.dll +Scripts/api-ms-win-core-processthreads-l1-1-0.dll +Scripts/api-ms-win-core-processthreads-l1-1-1.dll +Scripts/api-ms-win-core-profile-l1-1-0.dll +Scripts/api-ms-win-core-rtlsupport-l1-1-0.dll +Scripts/api-ms-win-core-string-l1-1-0.dll +Scripts/api-ms-win-core-synch-l1-1-0.dll +Scripts/api-ms-win-core-synch-l1-2-0.dll +Scripts/api-ms-win-core-sysinfo-l1-1-0.dll +Scripts/api-ms-win-core-timezone-l1-1-0.dll +Scripts/api-ms-win-core-util-l1-1-0.dll +Scripts/api-ms-win-crt-conio-l1-1-0.dll +Scripts/api-ms-win-crt-convert-l1-1-0.dll +Scripts/api-ms-win-crt-environment-l1-1-0.dll +Scripts/api-ms-win-crt-filesystem-l1-1-0.dll +Scripts/api-ms-win-crt-heap-l1-1-0.dll +Scripts/api-ms-win-crt-locale-l1-1-0.dll +Scripts/api-ms-win-crt-math-l1-1-0.dll +Scripts/api-ms-win-crt-multibyte-l1-1-0.dll +Scripts/api-ms-win-crt-private-l1-1-0.dll +Scripts/api-ms-win-crt-process-l1-1-0.dll +Scripts/api-ms-win-crt-runtime-l1-1-0.dll +Scripts/api-ms-win-crt-stdio-l1-1-0.dll +Scripts/api-ms-win-crt-string-l1-1-0.dll +Scripts/api-ms-win-crt-time-l1-1-0.dll +Scripts/api-ms-win-crt-utility-l1-1-0.dll +Scripts/concrt140.dll +Scripts/deactivate.bat +Scripts/libffi-7.dll +Scripts/msvcp140_1.dll +Scripts/msvcp140_2.dll +Scripts/msvcp140.dll +Scripts/pip-3.8.exe +Scripts/pip.exe +Scripts/pip3.8.exe +Scripts/pip3.exe +Scripts/pydoc.bat +Scripts/pyexpat.pyd +Scripts/python.exe +Scripts/python3.dll +Scripts/python38.dll +Scripts/pythonw.exe +Scripts/select.pyd +Scripts/tcl86t.dll +Scripts/tk86t.dll +Scripts/ucrtbase.dll +Scripts/unicodedata.pyd +Scripts/vccorlib140.dll +Scripts/vcomp140.dll +Scripts/vcruntime140.dll +Scripts/wheel-3.8.exe +Scripts/wheel.exe +Scripts/wheel3.8.exe +Scripts/wheel3.exe +Scripts/winsound.pyd +Scripts/xlwings32-0.20.7.dll +Scripts/xlwings64-0.20.7.dll @@ -71,9 +71,6 @@ class JusticeSearchForm(Form): zapis_do = DateField(u'Zapsáno do:', format='%Y-%m-%d') zapis_od = DateField(u'Zapsáno od:', format='%Y-%m-%d') - - - class CompanyForm(Form): oddil = [('A', 'A'), ('B', 'B'), diff --git a/justice_main.py b/justice_main.py index ae38927..f8699bd 100644 --- a/justice_main.py +++ b/justice_main.py @@ -579,10 +579,10 @@ def delete_archive(file): # parse_to_DB("sro-actual-praha-2020.xml")
-def do_both():
- general_update("down")
- general_update("db_update")
+# def do_both():
+# general_update("down")
+# general_update("db_update")
-do_both()
+# do_both()
# cProfile.run('do_both()')
@@ -41,7 +41,7 @@ def search_results(search): 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) + 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)) @@ -154,12 +154,24 @@ def search_results_BACKUP(search): @app.route("/<int:ico>", methods=['GET', 'POST']) def extract(ico): qry = Company.query.join(Obce, Company.obec).join(Ulice, Company.ulice).join(Pravni_Forma, Company.pravni_forma).join(Insolvency_Events, isouter=True) + # qry = Company.query.join(Obce, Company.obec).join(Ulice, Company.ulice).join(Pravni_Forma, Company.pravni_forma).join(Insolvency_Events, Company.insolvence, isouter=True).join(Predmet_Podnikani, Company.predmet_podnikani).join(Predmet_Cinnosti, Company.predmet_cinnosti) qry = qry.filter(Company.ico == ico) # qry = qry.filter(Company.nazev.contains("prigo")) # qry = Obce.query results = qry.all() return render_template("extract.html", ico = ico, results = results) +@app.route("/<int:ico>-actual", methods=['GET', 'POST']) +def extract_actual(ico): + qry = Company.query.join(Obce, Company.obec).join(Ulice, Company.ulice).join(Pravni_Forma, Company.pravni_forma).join(Insolvency_Events, isouter=True) + # qry = Company.query.join(Obce, Company.obec).join(Ulice, Company.ulice).join(Pravni_Forma, Company.pravni_forma).join(Insolvency_Events, Company.insolvence, isouter=True).join(Predmet_Podnikani, Company.predmet_podnikani).join(Predmet_Cinnosti, Company.predmet_cinnosti) + qry = qry.filter(Company.ico == ico) + # qry = qry.filter(Company.nazev.contains("prigo")) + # qry = Obce.query + results = qry.all() + return render_template("extract-actual.html", ico = ico, results = results) + + @app.route('/new_company', methods=['GET', 'POST']) def new_company(): """ @@ -16,9 +16,15 @@ def convert_date_to_string(converted_date): return converted_date else: separated_string = converted_date.split("-") - converted_string = "".join([separated_string[2], ". ", convert_month_to_string(separated_string[1]), " ", separated_string[0]]) + converted_string = "".join([strip_zero_from_date(separated_string[2]), ". ", convert_month_to_string(separated_string[1]), " ", separated_string[0]]) return converted_string +def strip_zero_from_date(converted_date): + if converted_date[0] == "0": + return converted_date[1] + else: + return converted_date + def convert_month_to_string(my_month): if my_month == "01": return "ledna" @@ -123,8 +129,8 @@ class Company(db.Model): ulice = db.relationship("Ulice", secondary=ulice_association, backref="companies") pravni_forma = db.relationship("Pravni_Forma", secondary=pravni_forma_association, backref="companies") insolvence = db.relationship("Insolvency_Events", backref="companies") - predmet_podnikani = db.relationship("Predmety_Podnikani_Association", back_populates="company", lazy="joined") - predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association", back_populates="company", lazy="joined") + predmet_podnikani = db.relationship("Predmety_Podnikani_Association", back_populates="company") + predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association", back_populates="company") class Obce(db.Model): @@ -149,17 +155,17 @@ class Insolvency_Events(db.Model): __tablename__ = "insolvency_events" id = db.Column(db.Integer, primary_key=True) company_id = db.Column(db.String, db.ForeignKey("companies.id")) - company = relationship("Company", backref="insolvency_events") + company = db.relationship("Company", backref="insolvency_events") insolvency_event = db.Column(db.String) class Predmet_Podnikani(db.Model): __tablename__ = "predmety_podnikani" id = db.Column(db.Integer, primary_key=True) predmet_podnikani = db.Column(db.String) - company_predmet_podnikani = db.relationship("Predmety_Podnikani_Association", back_populates="predmet_podnikani", lazy="joined") + company_predmet_podnikani = db.relationship("Predmety_Podnikani_Association", back_populates="predmet_podnikani") class Predmet_Cinnosti(db.Model): __tablename__ = "predmety_cinnosti" id = db.Column(db.Integer, primary_key=True) predmet_cinnosti = db.Column(db.String) - company_predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association", back_populates="predmet_cinnosti", lazy="joined") + company_predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association", back_populates="predmet_cinnosti") diff --git a/templates/extract-actual.html b/templates/extract-actual.html new file mode 100644 index 0000000..231e1bc --- /dev/null +++ b/templates/extract-actual.html @@ -0,0 +1,165 @@ +{% include 'header.html' %} + +{% for row in results %} + +{% set insolvency_notes = [] %} +{% for elem in row.insolvence %} + {% set insolvency_notes = insolvency_notes.append(elem.insolvency_event) %} +{% endfor %} + +{% set predmety_podnikani_notes = [] %} +{% for i in range (row.predmet_podnikani|length) %} + {% if row.predmet_podnikani[i].vymaz_datum == 0 %} + {% set predmety_podnikani_notes = predmety_podnikani_notes.append(row.predmet_podnikani[i].predmet_podnikani.predmet_podnikani) %} + {% endif %} +{% endfor %} + +{% set predmety_cinnosti_notes = [] %} +{% for i in range (row.predmet_cinnosti|length) %} + {% if row.predmet_cinnosti[i].vymaz_datum == 0 %} + {% set predmety_cinnosti_notes = predmety_cinnosti_notes.append(row.predmet_cinnosti[i].predmet_cinnosti.predmet_cinnosti) %} + {% endif %} +{% endfor %} + +{% set zapis_split = row.zapis.split("-") %} +{% if zapis_split[1] == "01" %} + {% set mesic = "ledna" %} +{% elif zapis_split[1] == "02" %} + {% set mesic = "února" %} +{% elif zapis_split[1] == "03" %} + {% set mesic = "března" %} +{% elif zapis_split[1] == "04" %} + {% set mesic = "dubna" %} +{% elif zapis_split[1] == "05" %} + {% set mesic = "května" %} +{% elif zapis_split[1] == "06" %} + {% set mesic = "června" %} +{% elif zapis_split[1] == "07" %} + {% set mesic = "července" %} +{% elif zapis_split[1] == "08" %} + {% set mesic = "srpna" %} +{% elif zapis_split[1] == "09" %} + {% set mesic = "září" %} +{% elif zapis_split[1] == "10" %} + {% set mesic = "října" %} +{% elif zapis_split[1] == "11" %} + {% set mesic = "listopadu" %} +{% elif zapis_split[1] == "12" %} + {% set mesic = "prosince" %} +{% endif %} + +{% if zapis_split[2][0] == "0" %} + {% set den = zapis_split[2][1] %} +{% else %} + {% set den = zapis_split[2] %} +{% endif %} + +{% if row.soud == "MSPH" %} + {% set soud = "Městského soudu v Praze" %} +{% elif row.soud == "KSCB" %} + {% set soud = "Krajského soudu v Českých Budějovicích" %} +{% elif row.soud == "KSOS" %} + {% set soud = "Krajského soudu v Ostravě" %} +{% elif row.soud == "KSPL" %} + {% set soud = "Krajského soudu v Plzni" %} +{% elif row.soud == "KSBR" %} + {% set soud = "Krajského soudu v Brně" %} +{% elif row.soud == "KSHK" %} + {% set soud = "Krajského soudu v Hradci Králové" %} +{% elif row.soud == "KSUL" %} + {% set soud = "Krajského soudu v Ústí nad Labem" %} +{% endif %} + +{% if insolvency_notes|length > 0 %} + {% set table_style = "table table-danger" %} +{% elif loop.index % 2 == 0 %} + {% set table_style = "table table-light" %} +{% else %} + {% set table_style = "table table-secondary" %} +{% endif %} + +{% if row.ico|length != 8 %} + {% set ico_buffer = [] %} + {% for i in range (8 - row.ico|length) %} + {% set ico_buffer = ico_buffer.append("0") %} + {% endfor %} + +{% else %} + {% set ico_buffer = "" %} +{% endif %} + +<h1>Výpis z obchodního rejstříku</h1> +<h2>{{ row.nazev }}, {{ row.oddil }} {{ row.vlozka }} vedená u {{ soud }}</h2> +<p><a href="/">Zpět na vyhledání.</a></p> + +<table class= "table" style="width: 100%"> + <tr> + <td style="width:15%">Datum vzniku a zápisu:</td> + <td style="width:85%">{{den}}. {{mesic}} {{zapis_split[0]}}</td> + </tr> + <tr> + <td>Spisová značka:</td> + <td>{{ row.oddil }} {{ row.vlozka }} vedená u {{ soud }}</td> + </tr> + <tr> + <td>Obchodní firma:</td> + <td>{{ row.nazev }}</td> + </tr> + <tr> + <td>Sídlo:</td> + <td>{{ row.sidlo }}</td> + </tr> + <tr> + <td>Identifikační číslo:</td> + <td>{{ ico_buffer|join("") }}{{ row.ico }}</td> + </tr> + <tr> + <td>Právní forma:</td> + <td>{{ row.pravni_forma[0].pravni_forma }}</td> + </tr> + + {% if predmety_podnikani_notes|length > 0 %} + <tr> + <td>Předmět podnikání:</td> + <td>{{ predmety_podnikani_notes[0] }}</td> + </tr> + {% for i in range (1, predmety_podnikani_notes|length) %} + <tr> + <td></td> + <td>{{ predmety_podnikani_notes[i] }}</td> + </tr> + {% endfor %} + {% endif %} + + {% if predmety_cinnosti_notes|length > 0 %} + <tr> + <td>Předmět činnosti:</td> + <td>{{ predmety_cinnosti_notes[0] }}</td> + </tr> + {% for i in range (1, predmety_cinnosti_notes|length) %} + <tr> + <td></td> + <td>{{ predmety_cinnosti_notes[i] }}</td> + </tr> + {% endfor %} + {% endif %} + + {% if insolvency_notes|length > 0 %} + <tr> + <td>Údaje o insolvencích:</td> + <td>{{ insolvency_notes[0] }}</td> + <td></td> + </tr> + {% for i in range (1, insolvency_notes|length) %} + <tr> + <td></td> + <td>{{ insolvency_notes[i] }}</td> + <td></td> + </tr> + {% endfor %} + {% endif %} +</table> + +{% endfor %} + +{% include 'footer.html' %}
\ No newline at end of file diff --git a/templates/results2.html b/templates/results2.html index 9bed615..d5e360f 100644 --- a/templates/results2.html +++ b/templates/results2.html @@ -98,7 +98,7 @@ <td>Sídlo:</td> <td>{{ row.sidlo }}</td> <td><a href="/{{ row.ico }}">Úplný výpis</a></td> - <td></td> + <td><a href="/{{ row.ico }}-actual">Aktuální výpis</a></td> </tr> {% if insolvency_notes|length > 0 %} |