From 6915a4e807a14ca9ffa1553089e45839204afa03 Mon Sep 17 00:00:00 2001 From: thomaswoehlke <thomas.woehlke@gmail.com> Date: Wed, 26 May 2021 09:23:31 +0200 Subject: [PATCH] Refactoring: vaccination --- .../blueprints/data_rki/rki_views.py | 18 +++++++++ .../bundesland/one/rki_bundesland_one.html | 29 +++++++++++++++ .../one/rki_bundesland_one_pagination.html | 37 +++++++++++++++++++ .../all/rki_landkreis_all_table.html | 27 ++++++++++++++ .../all/rki_landkreis_all_table_head.html | 5 +++ 5 files changed, 116 insertions(+) create mode 100644 src/flask_covid19/blueprints/data_rki/templates/rki/bundesland/one/rki_bundesland_one.html create mode 100644 src/flask_covid19/blueprints/data_rki/templates/rki/bundesland/one/rki_bundesland_one_pagination.html create mode 100644 src/flask_covid19/blueprints/data_rki/templates/rki/landkreis/all/rki_landkreis_all_table.html create mode 100644 src/flask_covid19/blueprints/data_rki/templates/rki/landkreis/all/rki_landkreis_all_table_head.html diff --git a/src/flask_covid19/blueprints/data_rki/rki_views.py b/src/flask_covid19/blueprints/data_rki/rki_views.py index 2ab40897..56167f30 100644 --- a/src/flask_covid19/blueprints/data_rki/rki_views.py +++ b/src/flask_covid19/blueprints/data_rki/rki_views.py @@ -122,6 +122,24 @@ def url_rki_bundesland_all(page: int = 1): page_data=page_data, page_info=page_info) + +@app_rki.route('/bundesland/<int:bundesland_id>/page/<int:page>') +@app_rki.route('/bundesland/<int:bundesland_id>') +def url_rki_bundesland_one(bundesland_id: int, page: int = 1): + page_info = WebPageContent('RKI', "Bundesland", "One") + try: + location_group = RkiBundesland.get_by_id(bundesland_id) + page_data = RkiLandkreis.get_by_location_group(location_group, page) + page_info = WebPageContent('RKI', "Bundesland", location_group.location_group) + except OperationalError: + flash("No date_reported in the database.") + page_data = None + return render_template( + 'rki/bundesland/one/rki_bundesland_one.html', + location_group=location_group, + page_data=page_data, + page_info=page_info) + # ------------------------------------------------------------------------ # Celery TASKS # ------------------------------------------------------------------------ diff --git a/src/flask_covid19/blueprints/data_rki/templates/rki/bundesland/one/rki_bundesland_one.html b/src/flask_covid19/blueprints/data_rki/templates/rki/bundesland/one/rki_bundesland_one.html new file mode 100644 index 00000000..95b53d0d --- /dev/null +++ b/src/flask_covid19/blueprints/data_rki/templates/rki/bundesland/one/rki_bundesland_one.html @@ -0,0 +1,29 @@ +{% extends 'app_application/layout/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'owid/navigation/owid_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'rki/bundesland/one/rki_bundesland_one_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'rki/landkreis/all/rki_landkreis_all_table.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'rki/bundesland/one/rki_bundesland_one_pagination.html' %} + </div> + </div> + </div> +{% endblock %} + + +{% block footer_container %} + +{% endblock %} diff --git a/src/flask_covid19/blueprints/data_rki/templates/rki/bundesland/one/rki_bundesland_one_pagination.html b/src/flask_covid19/blueprints/data_rki/templates/rki/bundesland/one/rki_bundesland_one_pagination.html new file mode 100644 index 00000000..9b76bab3 --- /dev/null +++ b/src/flask_covid19/blueprints/data_rki/templates/rki/bundesland/one/rki_bundesland_one_pagination.html @@ -0,0 +1,37 @@ + {% if page_data.pages > 1 %} + <!-- previous page --> + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for('rki.url_rki_bundesland_one', bundesland_id=location_group.id, page=page_data.prev_num) }}">Previous</a> + </li> + {% endif %} + <!-- all page numbers --> + {% for page_num in page_data.iter_pages() %} + {% if page_num %} + {% if page_num != page_data.page %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for('rki.url_rki_bundesland_one', bundesland_id=location_group.id, page=page_num) }}">{{ page_num }}</a> + </li> + {% else %} + <li class="page-item active"> + <a class="page-link" href="#">{{ page_num }}</a> + </li> + {% endif %} + {% else %} + <li class="page-item"> + <span class="ellipsis page-link my-page-item-ellipsis-page-link">…</span> + </li> + {% endif %} + {% endfor %} + <!-- next page --> + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for('rki.url_rki_bundesland_one', bundesland_id=location_group.id, page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/flask_covid19/blueprints/data_rki/templates/rki/landkreis/all/rki_landkreis_all_table.html b/src/flask_covid19/blueprints/data_rki/templates/rki/landkreis/all/rki_landkreis_all_table.html new file mode 100644 index 00000000..ff09454b --- /dev/null +++ b/src/flask_covid19/blueprints/data_rki/templates/rki/landkreis/all/rki_landkreis_all_table.html @@ -0,0 +1,27 @@ + <div class="table-responsive"> + <table class="table table-hover table-striped table-dark"> + <thead class="table-secondary"> + {% include 'rki/landkreis/all/rki_landkreis_all_table_head.html' %} + </thead> + <tbody> + {% for rki_landkreis in page_data.items %} + <tr> + <td> + <a href="{{ url_for( 'owid.url_rki_bundesland_all' ) }}"> + {{ rki_landkreis.location_group.location_group }} + </a> + </td> + <td> + {{ rki_landkreis.id_landkreis }} + </td> + <td> + {{ rki_landkreis.location }} + </td> + </tr> + {% endfor %} + </tbody> + <tfoot> + {% include 'rki/landkreis/all/rki_landkreis_all_table_head.html' %} + </tfoot> + </table> + </div> \ No newline at end of file diff --git a/src/flask_covid19/blueprints/data_rki/templates/rki/landkreis/all/rki_landkreis_all_table_head.html b/src/flask_covid19/blueprints/data_rki/templates/rki/landkreis/all/rki_landkreis_all_table_head.html new file mode 100644 index 00000000..df4905b3 --- /dev/null +++ b/src/flask_covid19/blueprints/data_rki/templates/rki/landkreis/all/rki_landkreis_all_table_head.html @@ -0,0 +1,5 @@ + <tr> + <th scope="col">bundesland</th> + <th scope="col">id landkreis</th> + <th scope="col">landkreis</th> + </tr> -- GitLab