diff --git a/app.py b/app.py index 825b8b731b7ef9709f33f83968d1fd984aaf7a7c..1a189826f6fd1d8dc130d6031bc91d188aee416e 100644 --- a/app.py +++ b/app.py @@ -389,6 +389,66 @@ def url_who_country(country_id, page=1): page_info=page_info) +@app.route('/who/country/<int:country_id>/cases_new/page/<int:page>') +@app.route('/who/country/<int:country_id>/cases_new') +def url_who_country_cases_new(country_id, page=1): + who_country = WhoCountry.get_by_id(country_id) + page_data = WhoGlobalData.get_data_for_country_order_by_cases_new(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'who/who_country_one_cases_new.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + +@app.route('/who/country/<int:country_id>/cases_cumulative/page/<int:page>') +@app.route('/who/country/<int:country_id>/cases_cumulative') +def url_who_country_cases_cumulative(country_id, page=1): + who_country = WhoCountry.get_by_id(country_id) + page_data = WhoGlobalData.get_data_for_country_order_by_cases_cumulative(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'who/who_country_one_cases_cumulative.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + +@app.route('/who/country/<int:country_id>/deaths_new/page/<int:page>') +@app.route('/who/country/<int:country_id>/deaths_new') +def url_who_country_deaths_new(country_id, page=1): + who_country = WhoCountry.get_by_id(country_id) + page_data = WhoGlobalData.get_data_for_country_order_by_deaths_new(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'who/who_country_one_deaths_new.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + +@app.route('/who/country/<int:country_id>/deaths_cumulative/page/<int:page>') +@app.route('/who/country/<int:country_id>/deaths_cumulative') +def url_who_country_deaths_cumulative(country_id, page=1): + who_country = WhoCountry.get_by_id(country_id) + page_data = WhoGlobalData.get_data_for_country_order_by_deaths_cumulative(who_country, page) + page_info = ApplicationPage(who_country.country, + "Country "+who_country.country_code, + "Data per Day in Country "+who_country.country+" of WHO Region "+who_country.region.region) + return render_template( + 'who/who_country_one_deaths_cumulative.html', + who_country=who_country, + page_data=page_data, + page_info=page_info) + + @app.route('/who/germany/page/<int:page>') @app.route('/who/germany') def url_who_germany(page=1): diff --git a/org/woehlke/covid19/who/who_model.py b/org/woehlke/covid19/who/who_model.py index 63cbc0f51bc77bc42dd9adfd07ceffa03e69b712..714bb2d8d470ef74bb1a6e3b2aedaef0283867d5 100644 --- a/org/woehlke/covid19/who/who_model.py +++ b/org/woehlke/covid19/who/who_model.py @@ -256,6 +256,50 @@ class WhoGlobalData(db.Model): cls.deaths_cumulative.desc() ).paginate(page, per_page=ITEMS_PER_PAGE) + @classmethod + def get_data_for_country_order_by_cases_new(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).subqueryload(WhoCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.cases_new.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_country_order_by_cases_cumulative(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).subqueryload(WhoCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.cases_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_country_order_by_deaths_new(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).subqueryload(WhoCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_new.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def get_data_for_country_order_by_deaths_cumulative(cls, who_country, page): + return db.session.query(cls).filter( + cls.country_id == who_country.id + ).populate_existing().options( + joinedload(cls.country).subqueryload(WhoCountry.region), + joinedload(cls.date_reported) + ).order_by( + cls.deaths_cumulative.desc() + ).paginate(page, per_page=ITEMS_PER_PAGE) + class WhoGlobalDataImportTable(db.Model): __tablename__ = 'who_global_data_import' diff --git a/templates/who/fragment_who_global_data_table_country.html b/templates/who/fragment_who_global_data_table_country.html new file mode 100644 index 0000000000000000000000000000000000000000..3ff6ffa44bf8c1374379437f9290912ef98e5e5f --- /dev/null +++ b/templates/who/fragment_who_global_data_table_country.html @@ -0,0 +1,66 @@ + <table class="table table-hover table-striped table-dark"> + <thead> + <tr> + <th scope="col">date reported</th> + <th scope="col"> + <a href="/who/country/{{ who_country.id }}/deaths_new"> + deaths new + </a> + </th> + <th scope="col"> + <a href="/who/country/{{ who_country.id }}/cases_new"> + cases new + </a> + </th> + <th scope="col"> + <a href="/who/country/{{ who_country.id }}/deaths_cumulative"> + deaths cumulative + </a> + </th> + <th scope="col"> + <a href="/who/country/{{ who_country.id }}/cases_cumulative"> + cases cumulative + </a> + </th> + <th scope="col">country code</th> + <th scope="col">country</th> + <th scope="col">region</th> + </tr> + </thead> + <tbody> + {% for who_global_data in page_data.items %} + <tr> + <th> + {{ who_global_data.date_reported.date_reported }} + </th> + <td> + {{ who_global_data.deaths_new }} + </td> + <td> + {{ who_global_data.cases_new }} + </td> + <td> + {{ who_global_data.deaths_cumulative }} + </td> + <td> + {{ who_global_data.cases_cumulative }} + </td> + <td> + <a href="/who/country/{{ who_global_data.country.id }}"> + {{ who_global_data.country.country_code }} + </a> + </td> + <td> + <a href="/who/country/{{ who_global_data.country.id }}"> + {{ who_global_data.country.country }} + </a> + </td> + <th> + <a href="/who/region/{{ who_global_data.country.region.id }}"> + {{ who_global_data.country.region.region }} + </a> + </th> + </tr> + {% endfor %} + </tbody> + </table> \ No newline at end of file diff --git a/templates/who/who_country_germany.html b/templates/who/who_country_germany.html index 1b719585be32dd81cd5484384fe5720678656141..419ba32e1895a1f75fe840b5cde9e93fefac2e8a 100644 --- a/templates/who/who_country_germany.html +++ b/templates/who/who_country_germany.html @@ -57,7 +57,7 @@ </ul> {% endif %} - {% include 'who/fragment_who_global_data_table.html' %} + {% include 'who/fragment_who_global_data_table_country.html' %} {% endblock %} diff --git a/templates/who/who_country_one.html b/templates/who/who_country_one.html index cb7d837ba171a10479403f686c9a249500952df3..f4b18ed10510c95176631df280e80b63c06b8c9f 100644 --- a/templates/who/who_country_one.html +++ b/templates/who/who_country_one.html @@ -57,7 +57,7 @@ </ul> {% endif %} - {% include 'who/fragment_who_global_data_table.html' %} + {% include 'who/fragment_who_global_data_table_country.html' %} {% endblock %} diff --git a/templates/who/who_country_one_cases_cumulative.html b/templates/who/who_country_one_cases_cumulative.html new file mode 100644 index 0000000000000000000000000000000000000000..77bc7e9cec68c81de33cd0e46436d40f8f77319c --- /dev/null +++ b/templates/who/who_country_one_cases_cumulative.html @@ -0,0 +1,71 @@ +{% extends 'page_layout.html' %} + +{% block navigation_breadcrumb %} + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="/who/region/all">Regions</a></li> + <li class="breadcrumb-item active" aria-current="page">Countries</li> + </ol> + </nav> +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_who.html' %} +{% endblock %} + +{% block main_container %} + + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'url_who_country_cases_cumulative', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% 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( 'url_who_country_cases_cumulative', country_id=who_country.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 %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'url_who_country_cases_cumulative', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'who/fragment_who_global_data_table_country.html' %} + +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/templates/who/who_country_one_cases_new.html b/templates/who/who_country_one_cases_new.html new file mode 100644 index 0000000000000000000000000000000000000000..1b4409c446a60f8c3071e97f3f464b65542d9888 --- /dev/null +++ b/templates/who/who_country_one_cases_new.html @@ -0,0 +1,71 @@ +{% extends 'page_layout.html' %} + +{% block navigation_breadcrumb %} + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="/who/region/all">Regions</a></li> + <li class="breadcrumb-item active" aria-current="page">Countries</li> + </ol> + </nav> +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_who.html' %} +{% endblock %} + +{% block main_container %} + + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'url_who_country_cases_new', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% 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( 'url_who_country_cases_new', country_id=who_country.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 %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'url_who_country_cases_new', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'who/fragment_who_global_data_table_country.html' %} + +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/templates/who/who_country_one_deaths_cumulative.html b/templates/who/who_country_one_deaths_cumulative.html new file mode 100644 index 0000000000000000000000000000000000000000..e447cc218c24429160bfb18b6a16be407ca0ac30 --- /dev/null +++ b/templates/who/who_country_one_deaths_cumulative.html @@ -0,0 +1,71 @@ +{% extends 'page_layout.html' %} + +{% block navigation_breadcrumb %} + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="/who/region/all">Regions</a></li> + <li class="breadcrumb-item active" aria-current="page">Countries</li> + </ol> + </nav> +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_who.html' %} +{% endblock %} + +{% block main_container %} + + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'url_who_country_deaths_cumulative', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% 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( 'url_who_country_deaths_cumulative', country_id=who_country.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 %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'url_who_country_deaths_cumulative', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'who/fragment_who_global_data_table_country.html' %} + +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file diff --git a/templates/who/who_country_one_deaths_new.html b/templates/who/who_country_one_deaths_new.html new file mode 100644 index 0000000000000000000000000000000000000000..62eec9a1db88805ea9bb00c5454fd6b86479909d --- /dev/null +++ b/templates/who/who_country_one_deaths_new.html @@ -0,0 +1,71 @@ +{% extends 'page_layout.html' %} + +{% block navigation_breadcrumb %} + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="/">Home</a></li> + <li class="breadcrumb-item"><a href="/who/region/all">Regions</a></li> + <li class="breadcrumb-item active" aria-current="page">Countries</li> + </ol> + </nav> +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_who.html' %} +{% endblock %} + +{% block main_container %} + + {% if page_data.pages > 1 %} + <ul class="pagination"> + {% if page_data.has_prev %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'url_who_country_deaths_new', country_id=who_country.id, page=page_data.prev_num) }}"> + Previous + </a> + </li> + {% endif %} + {% 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( 'url_who_country_deaths_new', country_id=who_country.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 %} + {% if page_data.has_next %} + <li class="page-item"> + <a class="page-link" + href="{{ url_for( 'url_who_country_deaths_new', country_id=who_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'who/fragment_who_global_data_table_country.html' %} + +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} \ No newline at end of file