diff options
-rw-r--r-- | app.py | 3 | ||||
-rw-r--r-- | forms.py | 24 | ||||
-rw-r--r-- | main.py | 53 | ||||
-rw-r--r-- | templates/header.html | 2 | ||||
-rw-r--r-- | templates/results_entities.html | 10 | ||||
-rw-r--r-- | templates/search_form_entity.html | 59 | ||||
-rw-r--r-- | templates/search_form_person.html | 1 |
7 files changed, 146 insertions, 6 deletions
@@ -14,7 +14,8 @@ from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///justice.db' app.config["SQLALCHEMY_ECHO"] = True -app.secret_key = "123456" app.debug = True +# CHANGE THIS FOR PRODUCTION :) +app.secret_key = "123456" toolbar = DebugToolbarExtension(app) db = SQLAlchemy(app)
\ No newline at end of file @@ -82,8 +82,7 @@ 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): - +class PersonSearchForm(Form): # VYMAZAT DUPLICITU search_options = [("text_anywhere","Kedkoliv v textu"), ("text_beginning","Začátek výrazu"), @@ -103,7 +102,28 @@ class PersonSearchForm(Form): person_actual_selection = SelectField('', choices=actual_options) 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é"),] + + entity_name_search = StringField(u'Název:') + entity_name_search_selection = SelectField('', choices=search_options) + entity_name_search_actual = SelectField('', choices=actual_options) + entity_number_search = StringField(u'Identifikační číslo:') + entity_number_search_selection = SelectField('', choices=search_options) + entity_number_search_actual = SelectField('', choices=actual_options) + + foreign_entity_number_search = StringField(u'Zahraniční registrační číslo:') + foreign_entity_number_search_selection = SelectField('', choices=search_options) + foreign_entity_number_search_actual = SelectField('', choices=actual_options) + class CompanyForm(Form): oddil = [('A', 'A'), ('B', 'B'), @@ -1,6 +1,6 @@ from app import app from db_setup import init_db, db_session -from forms import JusticeSearchForm, CompanyForm, PersonSearchForm +from forms import 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 @@ -32,6 +32,16 @@ def search_person(): return render_template('search_form_person.html', form=search) +@app.route('/entity', methods=['GET', 'POST']) +def search_entity(): + search = EntitySearchForm(request.form) + print(search) + if request.method == 'POST': + return search_results_entity(search) + + return render_template('search_form_entity.html', form=search) + + @app.route('/results_person') def search_results_person(search): result = [] @@ -79,6 +89,47 @@ def search_results_person(search): table.border = True return render_template("results_persons.html", results=results, form=search, show_form = True, selection_method = actual_selection) +@app.route('/results_entity') +def search_results_entity(search): + entity_name = search.entity_name_search.data + entity_name_search_method = search.entity_name_search_selection.data + entity_name_actual_or_full = search.entity_name_search_actual.data + + entity_number = search.entity_number_search.data + entity_number_search_method = search.entity_number_search_selection.data + entity_number_actual_or_full = search.entity_name_search_actual.data + + qry = Pravnicka_Osoba.query + + 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 entity_name: + if entity_name_search_method == "text_anywhere": + qry = qry.filter(Pravnicka_Osoba.nazev.contains(entity_name)) + elif entity_name_search_method == "text_beginning": + qry = qry.filter(Pravnicka_Osoba.nazev.like(f'{entity_name}%')) + elif entity_name_search_method == "text_exact": + qry = qry.filter(Pravnicka_Osoba.nazev == entity_name) + + results = qry.all() + print(results) + + if not results: + flash('No results found!') + return redirect('/osoby') + + else: + table = Results(results) + table.border = True + return render_template("results_entities.html", results=results, form=search, show_form = True) + + @app.route('/results') def search_results(search): results = [] diff --git a/templates/header.html b/templates/header.html index 14b8bda..5b50d1a 100644 --- a/templates/header.html +++ b/templates/header.html @@ -13,7 +13,7 @@ <tr> <td><a href="/">Veřejný rejstřík podle subjektů</a></td> <td><a href="/osoby">Veřejný rejstřík podle fyzických osob v angažmá</a></td> - <td>Veřejný rejstřík podle právnických osob v angažmá (coming soon)</td> + <td><a href="/entity">Veřejný rejstřík podle právnických osob v angažmá</a></td> <td><a href="/trivia">Zajímavosti z obchodního rejstříku</a></td> </tr> </table>
\ No newline at end of file diff --git a/templates/results_entities.html b/templates/results_entities.html new file mode 100644 index 0000000..d81086e --- /dev/null +++ b/templates/results_entities.html @@ -0,0 +1,10 @@ +{% if show_form == True %} + {% include 'search_form_entity.html' %} +{% else %} + {% include 'header.html' %} +{% endif %} + +{{ results }} + + +{% include 'footer.html' %}
\ No newline at end of file diff --git a/templates/search_form_entity.html b/templates/search_form_entity.html new file mode 100644 index 0000000..f3ae970 --- /dev/null +++ b/templates/search_form_entity.html @@ -0,0 +1,59 @@ +{% include 'header.html' %} +<title>Justice Database</title> + +<h2>Justice Database</h2> + +<p></p><p> + +{% with messages = get_flashed_messages() %} + {% if messages %} + <ul class="flashes"> + {% for message in messages %} + <li>{{ message }}</li> + {% endfor %} + </ul> + {% endif %} +{% endwith %} + + +{% from "_formhelpers.html" import render_field %} + +<!-- NAME --> +<form method="post"> + <div class="row g-2"> + <div class="col-sm-3"> + {{ form.entity_name_search.label }} + </div> + <div class="col-sm"> + {{ form.entity_name_search()|safe }} {{ form.entity_name_search_selection }} {{ form.entity_name_search_actual }} + </div> + </div> + +<!-- ID No. --> + <div class="row g-2"> + <div class="col-sm-3"> + {{ form.entity_number_search.label }} + </div> + <div class="col-sm"> + {{ form.entity_number_search()|safe }} {{ form.entity_number_search_selection }} {{ form.entity_number_search_actual }} + </div> + </div> + +<!-- Foreign ID No. --> + <div class="row g-2"> + <div class="col-sm-3"> + {{ form.foreign_entity_number_search.label }} + </div> + <div class="col-sm"> + {{ form.foreign_entity_number_search()|safe }} {{ form.foreign_entity_number_search_selection }} {{ form.foreign_entity_number_search_actual }} + </div> + </div> + + </p> + <p><input type="submit" value="Search"> + </p> +</form> + +{% include 'footer.html' %} + + diff --git a/templates/search_form_person.html b/templates/search_form_person.html index 04d8544..30d4865 100644 --- a/templates/search_form_person.html +++ b/templates/search_form_person.html @@ -64,7 +64,6 @@ </p> </form> -<p><a href="/trivia">Další zajímvavé údaje z obchodního resjtříku.</a></p> {% include 'footer.html' %} |