diff options
author | SveterCZE <petr.smerkl@live.com> | 2021-02-08 23:58:26 +0100 |
---|---|---|
committer | SveterCZE <petr.smerkl@live.com> | 2021-02-08 23:58:26 +0100 |
commit | 3ffebe7318838781d02a2231de0dd16f404940cf (patch) | |
tree | 801c5d5d3f4f692f7250cd216af00e6dabda91aa | |
parent | d0e2a39f694324815e263f0587e6827f7ef26f09 (diff) | |
download | justice-3ffebe7318838781d02a2231de0dd16f404940cf.tar.gz |
minor tweaks - does not work so far
-rw-r--r-- | justice_main.py | 6 | ||||
-rw-r--r-- | main.py | 3 | ||||
-rw-r--r-- | models.py | 37 | ||||
-rw-r--r-- | templates/extract.html | 41 | ||||
-rw-r--r-- | templates/results2.html | 1 |
5 files changed, 69 insertions, 19 deletions
diff --git a/justice_main.py b/justice_main.py index 9c09f62..ae38927 100644 --- a/justice_main.py +++ b/justice_main.py @@ -10,7 +10,7 @@ from datetime import datetime # The function opens a file and parses the extracted data into the database
def parse_to_DB(file):
print("Processing ", str(file))
- conn = sqlite3.connect('justice-testing.db')
+ conn = sqlite3.connect('justice.db')
c = conn.cursor()
for event, element in etree.iterparse(file, tag="Subjekt"):
# Bugfix for companies which have been deleted but appear in the list of existing companies
@@ -573,7 +573,7 @@ def delete_archive(file): send2trash.send2trash(file)
-parse_to_DB("as-actual-ostrava-2021.xml")
+# parse_to_DB("as-actual-ostrava-2021.xml")
# parse_to_DB("ks-actual-ostrava-2021.xml")
@@ -583,6 +583,6 @@ def do_both(): general_update("down")
general_update("db_update")
-# do_both()
+do_both()
# cProfile.run('do_both()')
@@ -4,7 +4,7 @@ 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, Obce, Ulice, Pravni_Forma, Insolvency_Events +from models import Company, Obce, Ulice, Pravni_Forma, Insolvency_Events, Predmet_Podnikani, Predmety_Podnikani_Association from tables import Results init_db() @@ -97,6 +97,7 @@ def search_results(search): qry = qry.filter(Company.zapis >= zapsano_od) if zapsano_do: qry = qry.filter(Company.zapis <= zapsano_do) + results = qry.all() # else: # qry = db_session.query(Company) @@ -35,8 +35,24 @@ pravni_forma_association=db.Table("pravni_formy_relation", db.Column("pravni_forma_id", db.Integer, db.ForeignKey("pravni_formy.id"), nullable=False), ) -class Company(db.Model): +# predmety_podnikani_association = db.Table("predmety_podnikani_relation", +# db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False), +# db.Column("predmet_podnikani_id", db.Integer, db.ForeignKey("predmety_podnikani.id"), nullable=False), +# db.Column("zapis_datum", db.String), +# db.Column("vymaz_datum", db.String), +# ) + + +class Predmety_Podnikani_Association(db.Model): + __tablename__ = 'predmety_podnikani_relation' + company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), primary_key=True, nullable=False) + predmet_podnikani_id = db.Column(db.Integer, db.ForeignKey('predmety_podnikani.id'), nullable=False) + zapis_datum = db.Column(db.String) + child = db.relationship("Predmet_Podnikani", back_populates="company_predmet_podnikani", lazy="joined") + parent = db.relationship("Company", back_populates="predmet_podnikani", lazy="joined") + +class Company(db.Model): __tablename__ = "companies" id = db.Column(db.Integer, primary_key=True) ico = db.Column(db.String) @@ -50,6 +66,7 @@ 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="parent", lazy="joined") class Obce(db.Model): @@ -78,16 +95,8 @@ class Insolvency_Events(db.Model): insolvency_event = db.Column(db.String) -# class Association(db.Model): -# __tablename__ = "obce_relation" -# company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), primary_key=True) -# obec_id = db.Column(db.Integer, db.ForeignKey('obce.id')) - -# company = relationship("Company", back_populates = "Obce") -# obec = relationship("Obce", back_populates = "Company") - - - - - -# </soud:>
\ No newline at end of file +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="child", lazy="joined") diff --git a/templates/extract.html b/templates/extract.html index b4f75fb..eed67ba 100644 --- a/templates/extract.html +++ b/templates/extract.html @@ -78,40 +78,79 @@ <h2>{{ row.nazev }}, {{ row.oddil }} {{ row.vlozka }} vedená u {{ soud }}</h2> <p><a href="/">Zpět na vyhledání.</a></p> +{{ row.predmet_podnikani }} + <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> + <td style="width:60%">{{den}}. {{mesic}} {{zapis_split[0]}}</td> + <td style="width:25%"></td> </tr> <tr> <td>Spisová značka:</td> <td>{{ row.oddil }} {{ row.vlozka }} vedená u {{ soud }}</td> + <td></td> </tr> <tr> <td>Obchodní firma:</td> <td>{{ row.nazev }}</td> + <td></td> </tr> <tr> <td>Sídlo:</td> <td>{{ row.sidlo }}</td> + <td></td> </tr> <tr> <td>Identifikační číslo:</td> <td>{{ ico_buffer|join("") }}{{ row.ico }}</td> + <td></td> </tr> <tr> <td>Právní forma:</td> <td>{{ row.pravni_forma[0].pravni_forma }}</td> + <td></td> + </tr> + + <tr> + <td>Předmět podnikání - test:</td> + <td>{{ row.predmet_podnikani[0].child.predmet_podnikani }}</td> + <td>Zapsáno: {{ row.predmet_podnikani[0].zapis_datum }} <br> Vymazáno: {{ row.predmet_podnikani[0].vymaz_datum }} </td> + <td></td> + </tr> + + {% if row.predmet_podnikani|length == 1 %} + <tr> + <td>Předmět podnikání:</td> + <td>{{ row.predmet_podnikani }}</td> + <td>Zapsáno: {{ row.predmet_podnikani[0] }} <br> Vymazáno: {{ row.predmet_podnikani[0].vymaz_datum }} </td> </tr> + {% elif row.predmet_podnikani|length > 1 %} + <tr> + <td>Předmět podnikání:</td> + <td>{{ row.predmet_podnikani }}</td> + <td>Zapsáno: {{ row.predmet_podnikani[0].zapis_datum }} <br> Vymazáno: {{ row.predmet_podnikani[0].vymaz_datum }} </td> + </tr> + {% for i in range (1, row.predmet_podnikani|length) %} + <tr> + <td></td> + <td>{{ row.predmet_podnikani[i].predmet_podnikani }}</td> + <td>Zapsáno: {{ row.predmet_podnikani[i].zapis_datum.company_id }} <br> Vymazáno: {{ row.predmet_podnikani[i].vymaz_datum }} </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 %} diff --git a/templates/results2.html b/templates/results2.html index e0c62b6..9bed615 100644 --- a/templates/results2.html +++ b/templates/results2.html @@ -100,6 +100,7 @@ <td><a href="/{{ row.ico }}">Úplný výpis</a></td> <td></td> </tr> + {% if insolvency_notes|length > 0 %} {% for i in range (insolvency_notes|length) %} <tr> |