aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db_creation.py8
-rw-r--r--forms.py51
-rw-r--r--main.py157
-rw-r--r--models.py6
-rw-r--r--templates/extract.html6
-rw-r--r--templates/search_form.html18
-rw-r--r--templates/search_form_entity.html40
-rw-r--r--templates/search_form_person.html41
-rw-r--r--update_db.py50
9 files changed, 296 insertions, 81 deletions
diff --git a/db_creation.py b/db_creation.py
index c1f0cc1..a8fefe7 100644
--- a/db_creation.py
+++ b/db_creation.py
@@ -113,7 +113,9 @@ def create_tables(conn):
"prijmeni" TEXT,
"titul_za" TEXT,
"datum_naroz" TEXT,
- UNIQUE("titul_pred","jmeno","prijmeni","titul_za","datum_naroz"),
+ "adresa_id" INTEGER,
+ UNIQUE("titul_pred","jmeno","prijmeni","titul_za","datum_naroz","adresa_id"),
+ FOREIGN KEY("adresa_id") REFERENCES "adresy_v2"("id"),
PRIMARY KEY("id" AUTOINCREMENT)
); """
@@ -232,7 +234,9 @@ def create_tables(conn):
"ico" INTEGER,
"reg_cislo" INTEGER,
"nazev" TEXT,
- UNIQUE("ico","reg_cislo","nazev"),
+ "adresa_id" INTEGER,
+ UNIQUE("ico","reg_cislo","nazev","adresa_id"),
+ FOREIGN KEY("adresa_id") REFERENCES "adresy_v2"("id"),
PRIMARY KEY("id" AUTOINCREMENT)
); """
diff --git a/forms.py b/forms.py
index 9cbad2f..a6659cf 100644
--- a/forms.py
+++ b/forms.py
@@ -9,20 +9,16 @@ Created on Sun Jan 17 10:05:34 2021
from wtforms import Form, StringField, SelectField, BooleanField
from wtforms.fields.html5 import DateField
-class JusticeSearchForm(Form):
+# CREATE A GENERAL CLASS TO REMOVE DUPLICITIES?
+
+class GeneralSearchForm(Form):
search_options = [("text_anywhere","Kedkoliv v textu"),
("text_beginning","Začátek výrazu"),
("text_exact","Přesný výraz"),
]
actual_options = [("actual_results","Jen platné"),
("complete_results","Platné i neplatné"),]
- nazev_subjektu = StringField(u'Název subjektu:')
- nazev_subjektu_selection = SelectField('', choices=search_options)
- nazev_search_actual = SelectField('', choices=actual_options)
- ico_search = StringField(u'Identifikační číslo:')
- ico_search_selection = SelectField('', choices=search_options)
-
obec_search = StringField(u'Obec:')
obec_search_selection = SelectField('', choices=search_options)
obec_search_actual = SelectField('', choices=actual_options)
@@ -30,7 +26,26 @@ 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)
+
+class JusticeSearchForm(GeneralSearchForm):
+ search_options = GeneralSearchForm.search_options
+ actual_options = GeneralSearchForm.actual_options
+ nazev_subjektu = StringField(u'Název subjektu:')
+ nazev_subjektu_selection = SelectField('', choices=search_options)
+ nazev_search_actual = SelectField('', choices=actual_options)
+
+ ico_search = StringField(u'Identifikační číslo:')
+ ico_search_selection = SelectField('', choices=search_options)
+
oddil_search = StringField(u'Oddíl:')
oddil_search_selection = SelectField('', choices=search_options)
oddil_search_actual = SelectField('', choices=actual_options)
@@ -82,14 +97,9 @@ 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 PersonSearchForm(Form):
- # VYMAZAT DUPLICITU
- search_options = [("text_anywhere","Kedkoliv v textu"),
- ("text_beginning","Začátek výrazu"),
- ("text_exact","Přesný výraz"),
- ]
- actual_options = [("actual_results","Jen platné"),
- ("complete_results","Platné i neplatné"),]
+class PersonSearchForm(GeneralSearchForm):
+ search_options = GeneralSearchForm.search_options
+ actual_options = GeneralSearchForm.actual_options
fist_name_search = StringField(u'Jméno:')
fist_name_search_selection = SelectField('', choices=search_options)
@@ -103,14 +113,9 @@ class PersonSearchForm(Form):
birthday = DateField(u'Datum narození:', format='%Y-%m-%d')
-class EntitySearchForm(Form):
- # VYMAZAT DUPLICITU
- search_options = [("text_anywhere","Kedkoliv v textu"),
- ("text_beginning","Začátek výrazu"),
- ("text_exact","Přesný výraz"),
- ]
- actual_options = [("actual_results","Jen platné"),
- ("complete_results","Platné i neplatné"),]
+class EntitySearchForm(GeneralSearchForm):
+ search_options = GeneralSearchForm.search_options
+ actual_options = GeneralSearchForm.actual_options
entity_name_search = StringField(u'Název:')
entity_name_search_selection = SelectField('', choices=search_options)
diff --git a/main.py b/main.py
index ee090d3..5d43f97 100644
--- a/main.py
+++ b/main.py
@@ -1,5 +1,5 @@
from app import app
-from forms import JusticeSearchForm, CompanyForm, PersonSearchForm, EntitySearchForm
+from forms import GeneralSearchForm, JusticeSearchForm, CompanyForm, PersonSearchForm, EntitySearchForm
from flask import flash, render_template, request, redirect
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
@@ -14,7 +14,7 @@ from sqlalchemy import create_engine
@app.route('/', methods=['GET', 'POST'])
def index():
search = JusticeSearchForm(request.form)
- print(search)
+ # print(search)
if request.method == 'POST':
return search_results(search)
@@ -23,7 +23,7 @@ def index():
@app.route('/osoby', methods=['GET', 'POST'])
def search_person():
search = PersonSearchForm(request.form)
- print(search)
+ # print(search)
if request.method == 'POST':
return search_results_person(search)
@@ -32,7 +32,7 @@ def search_person():
@app.route('/entity', methods=['GET', 'POST'])
def search_entity():
search = EntitySearchForm(request.form)
- print(search)
+ # print(search)
if request.method == 'POST':
return search_results_entity(search)
@@ -51,6 +51,18 @@ def search_results_person(search):
birthday = search.birthday.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
+
+ co = search.co_search.data
+ co_search_method = search.co_search_selection.data
+
+ cp = search.cp_search.data
+ cp_search_method = search.cp_search_selection.data
+
actual_selection = search.person_actual_selection.data
qry = Fyzicka_Osoba.query
@@ -70,7 +82,43 @@ def search_results_person(search):
qry = qry.filter(Fyzicka_Osoba.prijmeni.like(f'{surname}%'))
elif surname_search_method == "text_exact":
qry = qry.filter(Fyzicka_Osoba.prijmeni == surname)
-
+
+ if obec:
+ qry = qry.join(Adresy_v2, Fyzicka_Osoba.adresa)
+ if obec_search_method == "text_anywhere":
+ qry = qry.filter(Adresy_v2.obec.contains(obec))
+ elif obec_search_method == "text_beginning":
+ qry = qry.filter(Adresy_v2.obec.like(f'{obec}%'))
+ elif obec_search_method == "text_exact":
+ qry = qry.filter(Adresy_v2.obec == obec)
+
+ if ulice:
+ qry = qry.join(Adresy_v2, Fyzicka_Osoba.adresa)
+ if ulice_search_method == "text_anywhere":
+ qry = qry.filter(Adresy_v2.ulice.contains(ulice))
+ elif ulice_search_method == "text_beginning":
+ 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(Adresy_v2, Fyzicka_Osoba.adresa)
+ 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(Adresy_v2, Fyzicka_Osoba.adresa)
+ 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 birthday:
qry = qry.filter(Fyzicka_Osoba.datum_naroz == birthday)
@@ -94,8 +142,17 @@ def search_results_entity(search):
entity_number = search.entity_number_search.data
entity_number_search_method = search.entity_number_search_selection.data
- # foreign_entity_number = search.foreign_entity_number_search.data
- # foreign_entity_number_search_method = search.foreign_entity_number_search_selection.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
+
+ co = search.co_search.data
+ co_search_method = search.co_search_selection.data
+
+ cp = search.cp_search.data
+ cp_search_method = search.cp_search_selection.data
actual_selection = search.entity_actual_selection.data
@@ -114,22 +171,6 @@ def search_results_entity(search):
qry1 = qry1.filter(Pravnicka_Osoba.reg_cislo == entity_number)
qry = qry.union(qry1)
- # if entity_number:
- # if entity_number_search_method == "text_anywhere":
- # qry = qry.filter(Pravnicka_Osoba.ico.contains(entity_number))
- # elif entity_number_search_method == "text_beginning":
- # qry = qry.filter(Pravnicka_Osoba.ico.like(f'{entity_number}%'))
- # elif entity_number_search_method == "text_exact":
- # qry = qry.filter(Pravnicka_Osoba.ico == entity_number)
-
- # if foreign_entity_number:
- # if foreign_entity_number_search_method == "text_anywhere":
- # qry = qry.filter(Pravnicka_Osoba.reg_cislo.contains(foreign_entity_number))
- # elif foreign_entity_number_search_method == "text_beginning":
- # qry = qry.filter(Pravnicka_Osoba.reg_cislo.like(f'{foreign_entity_number}%'))
- # elif foreign_entity_number_search_method == "text_exact":
- # qry = qry.filter(Pravnicka_Osoba.reg_cislo == foreign_entity_number)
-
if entity_name:
if entity_name_search_method == "text_anywhere":
qry = qry.filter(Pravnicka_Osoba.nazev.contains(entity_name))
@@ -138,6 +179,42 @@ def search_results_entity(search):
elif entity_name_search_method == "text_exact":
qry = qry.filter(Pravnicka_Osoba.nazev == entity_name)
+ if obec:
+ qry = qry.join(Adresy_v2, Pravnicka_Osoba.adresa)
+ if obec_search_method == "text_anywhere":
+ qry = qry.filter(Adresy_v2.obec.contains(obec))
+ elif obec_search_method == "text_beginning":
+ qry = qry.filter(Adresy_v2.obec.like(f'{obec}%'))
+ elif obec_search_method == "text_exact":
+ qry = qry.filter(Adresy_v2.obec == obec)
+
+ if ulice:
+ qry = qry.join(Adresy_v2, Pravnicka_Osoba.adresa)
+ if ulice_search_method == "text_anywhere":
+ qry = qry.filter(Adresy_v2.ulice.contains(ulice))
+ elif ulice_search_method == "text_beginning":
+ 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(Adresy_v2, Pravnicka_Osoba.adresa)
+ 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(Adresy_v2, Pravnicka_Osoba.adresa)
+ 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)
+
results = qry.all()
print(results)
@@ -178,6 +255,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 +348,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/models.py b/models.py
index 74764d3..797a5b1 100644
--- a/models.py
+++ b/models.py
@@ -228,6 +228,8 @@ class Pravnicka_Osoba(db.Model):
sole_shareholder_association = db.relationship("Jediny_Akcionar_Association")
statut_org_association = db.relationship("Statutarni_Organ_Clen_Association")
supervisory_board_member_association = db.relationship("Dozorci_Rada_Clen_Association")
+ adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'))
+ adresa = db.relationship("Adresy_v2")
class Fyzicka_Osoba(db.Model):
__tablename__ = "fyzicke_osoby"
@@ -237,11 +239,13 @@ class Fyzicka_Osoba(db.Model):
prijmeni = db.Column(db.String)
titul_za = db.Column(db.String)
datum_naroz = db.Column(MyType)
+ adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'))
statut_org_association = db.relationship("Statutarni_Organ_Clen_Association")
spolecnik_association = db.relationship("Spolecnici_Association")
prokurista_association = db.relationship("Prokurista_Association")
sole_shareholder_association = db.relationship("Jediny_Akcionar_Association")
supervisory_board_member_association = db.relationship("Dozorci_Rada_Clen_Association")
+ adresa = db.relationship("Adresy_v2")
def get_name(self):
joined_name = ""
@@ -339,7 +343,6 @@ class Podily_Association(db.Model):
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
druh_podilu_id = db.Column(db.Integer, db.ForeignKey('druhy_podilu.id'))
- # vklad_typ = db.Column(db.String)
vklad_typ = db.Column(MyCurrency)
vklad_text = db.Column(db.String)
souhrn_typ = db.Column(MyContribution)
@@ -474,7 +477,6 @@ class Zakladni_Kapital(db.Model):
splaceni_typ = db.Column(db.String)
splaceni_hodnota = db.Column(db.String)
- # def __repr__(self):
def my_rep(self):
joined_zk = ""
joined_zk += self.vklad_hodnota + " "
diff --git a/templates/extract.html b/templates/extract.html
index 3600cd5..0c4efd0 100644
--- a/templates/extract.html
+++ b/templates/extract.html
@@ -258,7 +258,7 @@
<td>{{ underlne_style_open|safe }}
{% if row.statutarni_organ_text[i].clenove[j].jmeno != None %}{{ row.statutarni_organ_text[i].clenove[j].jmeno }}
{% else %}{{ row.statutarni_organ_text[i].clenove[j].jmeno_po.nazev}}{% if row.statutarni_organ_text[i].clenove[j].jmeno_po.reg_cislo != 0 %}, reg č. {{ row.statutarni_organ_text[i].clenove[j].jmeno_po.reg_cislo }}{% endif %}{% if row.statutarni_organ_text[i].clenove[j].jmeno_po.ico != 0 %}, IČ <a href="/{{ row.statutarni_organ_text[i].clenove[j].jmeno_po.ico }}">{{ row.statutarni_organ_text[i].clenove[j].jmeno_po.ico }}</a>{% endif %} {% endif %}<br>
- {{ row.statutarni_organ_text[i].clenove[j].adresa }}
+ {{ row.statutarni_organ_text[i].clenove[j].adresa }}
{% if row.statutarni_organ_text[i].clenove[j].funkce_od != 0 %}<br>Den vzniku funkce: {{ row.statutarni_organ_text[i].clenove[j].funkce_od}}{% endif %}
{% if row.statutarni_organ_text[i].clenove[j].funkce_do != 0 %}<br>Den zániku funkce: {{ row.statutarni_organ_text[i].clenove[j].funkce_do}}{% endif %}
{% if row.statutarni_organ_text[i].clenove[j].clenstvi_od != 0 %}<br>Den vzniku členství: {{ row.statutarni_organ_text[i].clenove[j].clenstvi_od}}{% endif %}
@@ -343,7 +343,7 @@
<td>{{ underlne_style_open|safe }}
{% if row.dozorci_rada_text[i].clenove[j].jmeno != None %}{{ row.dozorci_rada_text[i].clenove[j].jmeno }}
{% else %}{{ row.dozorci_rada_text[i].clenove[j].jmeno_po.nazev}}{% if row.dozorci_rada_text[i].clenove[j].jmeno_po.reg_cislo != 0 %}, reg č. {{ row.dozorci_rada_text[i].clenove[j].jmeno_po.reg_cislo }}{% endif %}{% if row.dozorci_rada_text[i].clenove[j].jmeno_po.ico != 0 %}, IČ <a href="/{{ row.dozorci_rada_text[i].clenove[j].jmeno_po.ico }}">{{ row.dozorci_rada_text[i].clenove[j].jmeno_po.ico }}</a>{% endif %} {% endif %}<br>
- {{ row.dozorci_rada_text[i].clenove[j].adresa }}
+ {{ row.dozorci_rada_text[i].clenove[j].adresa }}
{% if row.dozorci_rada_text[i].clenove[j].funkce_od != 0 %}<br>Den vzniku funkce: {{ row.dozorci_rada_text[i].clenove[j].funkce_od}}{% endif %}
{% if row.dozorci_rada_text[i].clenove[j].funkce_do != 0 %}<br>Den zániku funkce: {{ row.dozorci_rada_text[i].clenove[j].funkce_do}}{% endif %}
{% if row.dozorci_rada_text[i].clenove[j].clenstvi_od != 0 %}<br>Den vzniku členství: {{ row.dozorci_rada_text[i].clenove[j].clenstvi_od}}{% endif %}
@@ -397,7 +397,7 @@
{% set underlne_style_close = "" %}
{% endif %}
<td>{{ underlne_style_open|safe }}
- {{ row.prokurista[i].jmeno }}<br>
+ {{ row.prokurista[i].jmeno }}<br>
{{ row.prokurista[i].adresa }}{% if row.prokurista[i].text_prokurista != "0" %}<br>{{ row.prokurista[i].text_prokurista }}{% endif %}{{ underlne_style_close|safe }}</td>
<td>{{ underlne_style_open|safe }} Zapsáno: {{ row.prokurista[i].zapis_datum }} {% if row.prokurista[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.prokurista[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td>
</tr>
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">
diff --git a/templates/search_form_entity.html b/templates/search_form_entity.html
index 7d3d0ed..9491dba 100644
--- a/templates/search_form_entity.html
+++ b/templates/search_form_entity.html
@@ -40,6 +40,46 @@
</div>
</div>
+<!-- MUNICIPALITY -->
+ <div class="row g-2">
+ <div class="col-sm-3">
+ {{ form.obec_search.label }}
+ </div>
+ <div class="col-sm">
+ {{ form.obec_search()|safe }} {{ form.obec_search_selection }}
+ </div>
+ </div>
+
+<!-- STREET -->
+ <div class="row g-2">
+ <div class="col-sm-3">
+ {{ form.ulice_search.label }}
+ </div>
+ <div class="col-sm">
+ {{ form.ulice_search()|safe }} {{ form.ulice_search_selection }}
+ </div>
+ </div>
+
+<!-- DESCR. NO. -->
+ <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 }}
+ </div>
+ </div>
+
+<!-- OREINT. NO. -->
+ <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 }}
+ </div>
+ </div>
+
<!-- Search -->
<div class="row g-2">
<div class="col-sm-3">
diff --git a/templates/search_form_person.html b/templates/search_form_person.html
index 30d4865..d2fafb8 100644
--- a/templates/search_form_person.html
+++ b/templates/search_form_person.html
@@ -49,6 +49,47 @@
</div>
</div>
+<!-- MUNICIPALITY -->
+ <div class="row g-2">
+ <div class="col-sm-3">
+ {{ form.obec_search.label }}
+ </div>
+ <div class="col-sm">
+ {{ form.obec_search()|safe }} {{ form.obec_search_selection }}
+ </div>
+ </div>
+
+<!-- STREET -->
+ <div class="row g-2">
+ <div class="col-sm-3">
+ {{ form.ulice_search.label }}
+ </div>
+ <div class="col-sm">
+ {{ form.ulice_search()|safe }} {{ form.ulice_search_selection }}
+ </div>
+ </div>
+
+<!-- DESCR. NO. -->
+ <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 }}
+ </div>
+ </div>
+
+<!-- OREINT. NO. -->
+ <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 }}
+ </div>
+ </div>
+
+<!-- SEARCH -->
<div class="row g-2">
<div class="col-sm-3">
Vyhledávat údaje:
diff --git a/update_db.py b/update_db.py
index aa4a877..6e51e78 100644
--- a/update_db.py
+++ b/update_db.py
@@ -200,19 +200,16 @@ def find_spolecnik(c, ICO, elem2, conn, primary_sql_key, element):
# 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 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)
- # adresa_id = find_and_store_address(c, elem)
adresa_id = find_sidlo(c, elem, primary_sql_key)
+ spolecnik_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element, adresa_id)
c.execute("INSERT INTO spolecnici (company_id, spolecnik_fo_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, spolecnik_fo_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik,))
c.execute ("SELECT last_insert_rowid()")
spolecnik_id = c.fetchone()[0]
- # print(ICO, spolecnik_fo_id, adresa_id)
else:
spol_ico = str(get_prop(elem, "osoba/ico"))
regCislo = str(get_prop(elem, "osoba/regCislo"))
- spolecnik_po_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo)
- # adresa_id = find_and_store_address(c, elem)
adresa_id = find_sidlo(c, elem, primary_sql_key)
+ spolecnik_po_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo, adresa_id)
c.execute("INSERT INTO spolecnici (company_id, spolecnik_po_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, spolecnik_po_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik,))
c.execute ("SELECT last_insert_rowid()")
spolecnik_id = c.fetchone()[0]
@@ -341,8 +338,8 @@ def find_prokura(c, ICO, elem2, conn, primary_sql_key, element):
zapis_datum = str(get_prop(elem, "zapisDatum"))
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_sidlo(c, elem, primary_sql_key)
+ prokurista_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element, adresa_id)
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:
zapis_datum = str(get_prop(elem, "zapisDatum"))
@@ -363,12 +360,12 @@ def find_sole_shareholder(c, ICO, elem2, conn, primary_sql_key, element):
if typ_akcionar == "P":
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_sidlo(c, elem, primary_sql_key)
+ akcionar_po_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo, adresa_id)
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_sidlo(c, elem, primary_sql_key)
+ akcionar_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element, adresa_id)
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:
print(f)
@@ -489,14 +486,14 @@ def find_clen_statut_org(c, ICO, elem, conn, relationship_table_key, element):
funkceDo = str(get_prop(elem, "funkceDo"))
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_sidlo(c, elem, relationship_table_key)
+ osoba_id = find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element, adresa_id)
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,))
if typ_osoby == "AngazmaPravnicke":
spol_ico = str(get_prop(elem, "osoba/ico"))
regCislo = str(get_prop(elem, "osoba/regCislo"))
- prav_osoba_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo)
adresa_id = find_sidlo(c, elem, relationship_table_key)
+ prav_osoba_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo, adresa_id)
c.execute("INSERT into statutarni_organ_clen_relation (statutarni_organ_id, prav_osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, prav_osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,))
except Exception as f:
print(f)
@@ -505,38 +502,38 @@ def insert_individual_relations_v2(c, ICO, conn, primary_sql_key, zapis_datum, v
insert_into_ancillary_table(c, elem, inserted_figure)
return 0
-def find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element):
+def find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element, adresa_id):
try:
jmeno = str(get_prop(elem, "osoba/jmeno"))
prijmeni = str(get_prop(elem, "osoba/prijmeni"))
datum_narozeni = str(get_prop(elem, "osoba/narozDatum"))
titulPred = str(get_prop(elem, "osoba/titulPred"))
titulZa = str(get_prop(elem, "osoba/titulZa"))
- insert_fyzicka_osoba(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni)
- osoba_id = find_osoba_id(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni)
+ insert_fyzicka_osoba(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni, adresa_id)
+ osoba_id = find_osoba_id(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni, adresa_id)
return osoba_id
except:
pass
-def insert_fyzicka_osoba(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni):
+def insert_fyzicka_osoba(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni, adresa_id):
try:
- c.execute("INSERT into fyzicke_osoby (titul_pred, jmeno, prijmeni, titul_za, datum_naroz) VALUES (?,?,?,?,?)", (titulPred, jmeno, prijmeni, titulZa, datum_narozeni,))
+ c.execute("INSERT into fyzicke_osoby (titul_pred, jmeno, prijmeni, titul_za, datum_naroz, adresa_id) VALUES (?,?,?,?,?,?)", (titulPred, jmeno, prijmeni, titulZa, datum_narozeni,adresa_id,))
except:
pass
-def find_osoba_id(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni):
+def find_osoba_id(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni, adresa_id):
try:
- anciallary_table_key = c.execute("SELECT id FROM fyzicke_osoby WHERE titul_pred = (?) and jmeno = (?) and prijmeni = (?) and titul_za = (?) and datum_naroz = (?)", (titulPred, jmeno, prijmeni, titulZa, datum_narozeni,))
+ anciallary_table_key = c.execute("SELECT id FROM fyzicke_osoby WHERE titul_pred = (?) and jmeno = (?) and prijmeni = (?) and titul_za = (?) and datum_naroz = (?) and adresa_id = (?)", (titulPred, jmeno, prijmeni, titulZa, datum_narozeni,adresa_id,))
anciallary_table_key = c.fetchone()[0]
return anciallary_table_key
except Exception as f:
print(f)
-def find_pravnicka_osoba(c, elem, spol_ico, regCislo):
+def find_pravnicka_osoba(c, elem, spol_ico, regCislo, adresa_id):
try:
nazev = str(get_prop(elem, "osoba/nazev"))
- insert_pravnicka_osoba(c, elem, spol_ico, regCislo, nazev)
- osoba_id = find_pravnicka_osoba_id(c, spol_ico, regCislo, nazev)
+ insert_pravnicka_osoba(c, elem, spol_ico, regCislo, nazev, adresa_id)
+ osoba_id = find_pravnicka_osoba_id(c, spol_ico, regCislo, nazev, adresa_id)
return osoba_id
except Exception as f:
print(f)
@@ -561,15 +558,14 @@ def find_clen_dr(c, ICO, elem, conn, relationship_table_key, element):
funkceDo = str(get_prop(elem, "funkceDo"))
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 = find_sidlo(c, elem, relationship_table_key)
+ osoba_id = find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element, adresa_id)
c.execute("INSERT into dr_organ_clen_relation (dozorci_rada_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,))
elif typ_osoby == "AngazmaPravnicke":
spol_ico = str(get_prop(elem, "osoba/ico"))
regCislo = str(get_prop(elem, "osoba/regCislo"))
- pravnicka_osoba_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo)
adresa_id = find_sidlo(c, elem, relationship_table_key)
+ pravnicka_osoba_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo, adresa_id)
c.execute("INSERT into dr_organ_clen_relation (dozorci_rada_id, pravnicka_osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, pravnicka_osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,))
except Exception as f:
print(f)
@@ -614,17 +610,17 @@ def find_druh_podilu_id(c, druhPodilu):
except Exception as f:
print(f)
-def find_pravnicka_osoba_id(c, spol_ico, regCislo, nazev):
+def find_pravnicka_osoba_id(c, spol_ico, regCislo, nazev, adresa_id):
try:
- anciallary_table_key = c.execute("SELECT id FROM pravnicke_osoby WHERE ico = (?) and reg_cislo = (?) and nazev = (?)", (spol_ico, regCislo, nazev,))
+ anciallary_table_key = c.execute("SELECT id FROM pravnicke_osoby WHERE ico = (?) and reg_cislo = (?) and nazev = (?) and adresa_id = (?)", (spol_ico, regCislo, nazev, adresa_id))
anciallary_table_key = c.fetchone()[0]
return anciallary_table_key
except Exception as f:
print(f)
-def insert_pravnicka_osoba(c, elem, spol_ico, regCislo, nazev):
+def insert_pravnicka_osoba(c, elem, spol_ico, regCislo, nazev, adresa_id):
try:
- c.execute("INSERT into pravnicke_osoby (ico, reg_cislo, nazev) VALUES (?,?,?)", (spol_ico, regCislo, nazev,))
+ c.execute("INSERT into pravnicke_osoby (ico, reg_cislo, nazev, adresa_id) VALUES (?,?,?, ?)", (spol_ico, regCislo, nazev, adresa_id,))
except:
pass