diff --git a/src/covid19/blueprints/owid/owid_views.py b/src/covid19/blueprints/owid/owid_views.py index 97f2b42161f66c2627d29cab9211a0e0555c8f84..db0d769ec1bfece492c254dfb2d616e3f2bf103e 100644 --- a/src/covid19/blueprints/owid/owid_views.py +++ b/src/covid19/blueprints/owid/owid_views.py @@ -34,7 +34,7 @@ admin.add_view(ModelView(OwidData, db.session, category="OWID")) @app_owid.route('/info') def url_owid_info(): - page_info = ApplicationPage('OWID',"Info") + page_info = ApplicationPage('OWID', "Info") return render_template( 'owid/owid_info.html', page_info=page_info) @@ -42,16 +42,31 @@ def url_owid_info(): @app_owid.route('/tasks') def url_owid_tasks(): - page_info = ApplicationPage('OWID',"Tasks") + page_info = ApplicationPage('OWID', "Tasks") return render_template( 'owid/owid_tasks.html', page_info=page_info) +@app_owid.route('/test/page/<int:page>') +@app_owid.route('/test') +def url_owid_test(page=1): + page_info = ApplicationPage('OWID', "Test") + try: + page_data = OwidImport.get_all_as_page(page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'owid/owid_test.html', + page_data=page_data, + page_info=page_info) + + @app_owid.route('/imported/page/<int:page>') @app_owid.route('/imported') def url_owid_imported(page=1): - page_info = ApplicationPage('OWID',"Last Import") + page_info = ApplicationPage('OWID', "Last Import") try: page_data = OwidImport.get_all_as_page(page) except OperationalError: @@ -66,7 +81,7 @@ def url_owid_imported(page=1): @app_owid.route('/date_reported/all/page/<int:page>') @app_owid.route('/date_reported/all') def url_owid_date_reported_all(page: int = 1): - page_info = ApplicationPage('OWID',"Date Reported", "All") + page_info = ApplicationPage('OWID', "Date Reported", "All") try: page_data = OwidDateReported.get_all_as_page(page) except OperationalError: diff --git a/src/covid19/blueprints/owid/templates/owid/fragments/fragment_owid_test_pagination.html b/src/covid19/blueprints/owid/templates/owid/fragments/fragment_owid_test_pagination.html new file mode 100644 index 0000000000000000000000000000000000000000..2309b8d355fa852559827188eba5b9ca1b7cc816 --- /dev/null +++ b/src/covid19/blueprints/owid/templates/owid/fragments/fragment_owid_test_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('owid.url_owid_test', 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('owid.url_owid_test', 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('owid.url_owid_test', page=page_data.next_num) }}">Next</a> + </li> + {% endif %} + </ul> + {% endif %} diff --git a/src/covid19/blueprints/owid/templates/owid/fragments/fragment_owid_test_table.html b/src/covid19/blueprints/owid/templates/owid/fragments/fragment_owid_test_table.html new file mode 100644 index 0000000000000000000000000000000000000000..0b5db3ad188514dfe5d3f23cf8e37f4a99c483ce --- /dev/null +++ b/src/covid19/blueprints/owid/templates/owid/fragments/fragment_owid_test_table.html @@ -0,0 +1,131 @@ + <table class="table table-hover table-striped table-dark"> + <thead> + <tr> + <th scope="col">iso_code</th> + <th scope="col">continent</th> + <th scope="col">location</th> + <th scope="col">date</th> + <th scope="col">total_cases</th> + <th scope="col">new_cases</th> + <th scope="col">new_cases_smoothed</th> + <th scope="col">total_deaths</th> + <th scope="col">new_deaths</th> + <th scope="col">new_deaths_smoothed</th> + <th scope="col">total_cases_per_million</th> + <th scope="col">new_cases_per_million</th> + <th scope="col">new_cases_smoothed_per_million</th> + <th scope="col">total_deaths_per_million</th> + <th scope="col">new_deaths_per_million</th> + <th scope="col">new_deaths_smoothed_per_million</th> + <th scope="col">reproduction_rate</th> + <th scope="col">icu_patients</th> + <th scope="col">icu_patients_per_million</th> + <th scope="col">hosp_patients</th> + <th scope="col">hosp_patients_per_million</th> + <th scope="col">weekly_icu_admissions</th> + <th scope="col">weekly_icu_admissions_per_million</th> + <th scope="col">weekly_hosp_admissions</th> + <th scope="col">weekly_hosp_admissions_per_million</th> + <th scope="col">new_tests</th> + <th scope="col">total_tests</th> + <th scope="col">total_tests_per_thousand</th> + <th scope="col">new_tests_per_thousand</th> + <th scope="col">new_tests_smoothed</th> + <th scope="col">new_tests_smoothed_per_thousand</th> + <th scope="col">positive_rate</th> + <th scope="col">tests_per_case</th> + <th scope="col">tests_units</th> + <th scope="col">total_vaccinations</th> + <th scope="col">people_vaccinated</th> + <th scope="col">people_fully_vaccinated</th> + <th scope="col">new_vaccinations</th> + <th scope="col">new_vaccinations_smoothed</th> + <th scope="col">total_vaccinations_per_hundred</th> + <th scope="col">people_vaccinated_per_hundred</th> + <th scope="col">people_fully_vaccinated_per_hundred</th> + <th scope="col">new_vaccinations_smoothed_per_million</th> + <th scope="col">stringency_index</th> + <th scope="col">population</th> + <th scope="col">population_density</th> + <th scope="col">median_age</th> + <th scope="col">aged_65_older</th> + <th scope="col">aged_70_older</th> + <th scope="col">gdp_per_capita</th> + <th scope="col">extreme_poverty</th> + <th scope="col">cardiovasc_death_rate</th> + <th scope="col">diabetes_prevalence</th> + <th scope="col">female_smokers</th> + <th scope="col">male_smokers</th> + <th scope="col">handwashing_facilities</th> + <th scope="col">hospital_beds_per_thousand</th> + <th scope="col">life_expectancy</th> + <th scope="col">human_development_index</th> + </tr> + </thead> + <tbody> + {% for owid_import in page_data.items %} + <tr> + <td>{{ owid_import.iso_code }}</td> + <td>{{ owid_import.continent }}</td> + <td>{{ owid_import.location }}</td> + <td>{{ owid_import.date }}</td> + <td>{{ owid_import.total_cases }}</td> + <td>{{ owid_import.new_cases }}</td> + <td>{{ owid_import.new_cases_smoothed }}</td> + <td>{{ owid_import.total_deaths }}</td> + <td>{{ owid_import.new_deaths }}</td> + <td>{{ owid_import.new_deaths_smoothed }}</td> + <td>{{ owid_import.total_cases_per_million }}</td> + <td>{{ owid_import.new_cases_per_million }}</td> + <td>{{ owid_import.new_cases_smoothed_per_million }}</td> + <td>{{ owid_import.total_deaths_per_million }}</td> + <td>{{ owid_import.new_deaths_per_million }}</td> + <td>{{ owid_import.new_deaths_smoothed_per_million }}</td> + <td>{{ owid_import.reproduction_rate }}</td> + <td>{{ owid_import.icu_patients }}</td> + <td>{{ owid_import.icu_patients_per_million }}</td> + <td>{{ owid_import.hosp_patients }}</td> + <td>{{ owid_import.hosp_patients_per_million }}</td> + <td>{{ owid_import.weekly_icu_admissions }}</td> + <td>{{ owid_import.weekly_icu_admissions_per_million }}</td> + <td>{{ owid_import.weekly_hosp_admissions }}</td> + <td>{{ owid_import.weekly_hosp_admissions_per_million }}</td> + <td>{{ owid_import.new_tests }}</td> + <td>{{ owid_import.total_tests }}</td> + <td>{{ owid_import.total_tests_per_thousand }}</td> + <td>{{ owid_import.new_tests_per_thousand }}</td> + <td>{{ owid_import.new_tests_smoothed }}</td> + <td>{{ owid_import.new_tests_smoothed_per_thousand }}</td> + <td>{{ owid_import.positive_rate }}</td> + <td>{{ owid_import.tests_per_case }}</td> + <td>{{ owid_import.tests_units }}</td> + <td>{{ owid_import.total_vaccinations }}</td> + <td>{{ owid_import.people_vaccinated }}</td> + <td>{{ owid_import.people_fully_vaccinated }}</td> + <td>{{ owid_import.new_vaccinations }}</td> + <td>{{ owid_import.new_vaccinations_smoothed }}</td> + <td>{{ owid_import.total_vaccinations_per_hundred }}</td> + <td>{{ owid_import.people_vaccinated_per_hundred }}</td> + <td>{{ owid_import.people_fully_vaccinated_per_hundred }}</td> + <td>{{ owid_import.new_vaccinations_smoothed_per_million }}</td> + <td>{{ owid_import.stringency_index }}</td> + <td>{{ owid_import.population }}</td> + <td>{{ owid_import.population_density }}</td> + <td>{{ owid_import.median_age }}</td> + <td>{{ owid_import.aged_65_older }}</td> + <td>{{ owid_import.aged_70_older }}</td> + <td>{{ owid_import.gdp_per_capita }}</td> + <td>{{ owid_import.extreme_poverty }}</td> + <td>{{ owid_import.cardiovasc_death_rate }}</td> + <td>{{ owid_import.diabetes_prevalence }}</td> + <td>{{ owid_import.female_smokers }}</td> + <td>{{ owid_import.male_smokers }}</td> + <td>{{ owid_import.handwashing_facilities }}</td> + <td>{{ owid_import.hospital_beds_per_thousand }}</td> + <td>{{ owid_import.life_expectancy }}</td> + <td>{{ owid_import.human_development_index }}</td> + </tr> + {% endfor %} + </tbody> + </table> + diff --git a/src/covid19/blueprints/owid/templates/owid/owid_tasks.html b/src/covid19/blueprints/owid/templates/owid/owid_tasks.html index ac9ecbd3c5325bc07afee4129594a2bf39a9d937..044e31ab856088740b3b403681c27613459ff7c8 100644 --- a/src/covid19/blueprints/owid/templates/owid/owid_tasks.html +++ b/src/covid19/blueprints/owid/templates/owid/owid_tasks.html @@ -8,6 +8,9 @@ <div class="row"> <div class="col"> <div class="btn-group-vertical" role="group" aria-label="Views"> + <a class="btn btn-danger btn-lg btn-block text-left" + href="{{ url_for('owid.url_owid_test') }}" + role="button">OWID :: TEST</a> <a class="btn btn-primary btn-lg btn-block text-left" href="{{ url_for( 'owid.url_task_owid_update_star_schema_initial') }}" role="button">OWID :: Task :: update :: star_schema :: initial</a> diff --git a/src/covid19/blueprints/owid/templates/owid/owid_test.html b/src/covid19/blueprints/owid/templates/owid/owid_test.html new file mode 100644 index 0000000000000000000000000000000000000000..aa9f3b961a39c56444573fe3e2dd8c99adba4993 --- /dev/null +++ b/src/covid19/blueprints/owid/templates/owid/owid_test.html @@ -0,0 +1,24 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'owid/fragments/fragment_owid_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% include 'owid/fragments/fragment_owid_test_pagination.html' %} + </div> + </div> + <div class="row"> + <div class="col"> + {% include 'owid/fragments/fragment_owid_test_table.html' %} + </div> + </div> + </div> +{% endblock %} + + +{% block footer_container %} + +{% endblock %} diff --git a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_views.py b/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_views.py index 08fca45522cb545972f4845598661a1e71583031..122343ed8fa2b81efc6cbb0aa8b6584b9de2e018 100644 --- a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_views.py +++ b/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_views.py @@ -56,6 +56,21 @@ def url_rki_bundeslaender_imported(page=1): page_info=page_info) +@app_rki_bundeslaender.route('/test/page/<int:page>') +@app_rki_bundeslaender.route('/test') +def url_rki_bundeslaender_test(page=1): + page_info = ApplicationPage('RKI', "TEST") + try: + page_data = RkiBundeslaenderImport.get_all_as_page(page) + except OperationalError: + flash("No data in the database.") + page_data = None + return render_template( + 'rki_bundeslaender/rki_bundeslaender_test.html', + page_data=page_data, + page_info=page_info) + + # ------------------------------------------------------------------------ # Celery TASKS # ------------------------------------------------------------------------ diff --git a/src/covid19/blueprints/rki_bundeslaender/templates/rki_bundeslaender/rki_bundeslaender_tasks.html b/src/covid19/blueprints/rki_bundeslaender/templates/rki_bundeslaender/rki_bundeslaender_tasks.html index 5443bb7a3b10c408ddfd0b08a77ddac311eb7b3a..48b6b4c4a57b6b82e640c21f3df2ce3e8d7a7c2d 100644 --- a/src/covid19/blueprints/rki_bundeslaender/templates/rki_bundeslaender/rki_bundeslaender_tasks.html +++ b/src/covid19/blueprints/rki_bundeslaender/templates/rki_bundeslaender/rki_bundeslaender_tasks.html @@ -13,6 +13,9 @@ <div class="row"> <div class="col"> <div class="btn-group-vertical" role="group" aria-label="Views"> + <a class="btn btn-danger btn-lg btn-block text-left" + href="{{ url_for('rki_bundeslaender.url_rki_bundeslaender_test') }}" + role="button">RKI :: Bundeslaender :: TEST</a> <a class="btn btn-primary btn-lg btn-block text-left" href="{{ url_for('rki_bundeslaender.url_rki_bundeslaender_task_update_starschema_initial') }}" role="button">RKI :: Bundeslaender :: Task :: update :: star_schema :: initial</a> diff --git a/src/covid19/blueprints/rki_bundeslaender/templates/rki_bundeslaender/rki_bundeslaender_test.html b/src/covid19/blueprints/rki_bundeslaender/templates/rki_bundeslaender/rki_bundeslaender_test.html new file mode 100644 index 0000000000000000000000000000000000000000..44d1d01572cec034da69bca433ad7d3387a80e4e --- /dev/null +++ b/src/covid19/blueprints/rki_bundeslaender/templates/rki_bundeslaender/rki_bundeslaender_test.html @@ -0,0 +1,93 @@ +{% extends 'application/page_layout.html' %} + +{% block content %} + {{super()}} + {% include 'rki_bundeslaender/fragments/fragment_rki_bundeslaender_navtabs.html' %} + + <div class="container"> + <div class="row"> + <div class="col"> + {% 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_bundeslaender.url_rki_bundeslaender_test', 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_bundeslaender.url_rki_bundeslaender_test', 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_bundeslaender.url_rki_bundeslaender_test', page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + </div> + </div> + <div class="row"> + <div class="col"> + <table class="table table-hover table-striped"> + <thead> + <tr> + <th scope="col">date_reported</th> + <th scope="col">country_code</th> + <th scope="col">country</th> + <th scope="col">who_region</th> + <th scope="col">new_cases</th> + <th scope="col">cumulative_cases</th> + <th scope="col">new_deaths</th> + <th scope="col">cumulative_deaths</th> + </tr> + </thead> + <tbody> + {% for data_item in page_data.items %} + <tr> + <td>{{ who_global_data_import.date_reported }}</td> + <td>{{ who_global_data_import.country_code }}</td> + <td>{{ who_global_data_import.country }}</td> + <td>{{ who_global_data_import.who_region }}</td> + <td>{{ who_global_data_import.new_cases }}</td> + <td>{{ who_global_data_import.cumulative_cases }}</td> + <td>{{ who_global_data_import.new_deaths }}</td> + <td>{{ who_global_data_import.cumulative_deaths }}</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + </div> + </div> +{% endblock %} + + +{% block footer_container %} + +{% endblock %}