diff --git a/README.md b/README.md index 10f09c40679cc56f9c3461e7100aa3928f40d465..1590740d438933ff71265c6c2ef19d3dac06b0dc 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ class WhoGlobalDataImportTable(db.Model): ### 0.0.11 Release * Fixed #26 /admin/database/dump -* Issue #43 /europe/date_reported +* Fixed #43 /europe/date_reported * Issue #44 /europe/continent * Issue #45 /europe/country * Issue #46 /europe/country/germany diff --git a/app.py b/app.py index 8ac85d1bd4d11a9665165edbf830c6bd3118386e..961056b170a3ab5c6be96a4b1602fd7414aa94c3 100644 --- a/app.py +++ b/app.py @@ -285,12 +285,40 @@ def url_europe_date_reported_all(page=1): @app.route('/europe/date_reported/<int:europe_date_reported_id>/page/<int:page>') @app.route('/europe/date_reported/<int:europe_date_reported_id>') -def url_europe_date_reported_one(europe_date_reported_id, page=1): +@app.route('/europe/date_reported/notification_rate/<int:europe_date_reported_id>/page/<int:page>') +@app.route('/europe/date_reported/notification_rate/<int:europe_date_reported_id>') +def url_europe_date_reported_one_notification_rate(europe_date_reported_id, page=1): page_info = ApplicationPage('Europe', "date_reported") europe_date_reported = EuropeDateReported.get_by_id(europe_date_reported_id) - page_data = EuropeData.find_by_date_reported(europe_date_reported, page) + page_data = EuropeData.find_by_date_reported_notification_rate(europe_date_reported, page) return render_template( - 'europe/europe_date_reported_one.html', + 'europe/europe_date_reported_one_notification_rate.html', + europe_date_reported=europe_date_reported, + page_data=page_data, + page_info=page_info) + + +@app.route('/europe/date_reported/deaths_weekly/<int:europe_date_reported_id>/page/<int:page>') +@app.route('/europe/date_reported/deaths_weekly/<int:europe_date_reported_id>') +def url_europe_date_reported_one_deaths_weekly(europe_date_reported_id, page=1): + page_info = ApplicationPage('Europe', "date_reported") + europe_date_reported = EuropeDateReported.get_by_id(europe_date_reported_id) + page_data = EuropeData.find_by_date_reported_deaths_weekly(europe_date_reported, page) + return render_template( + 'europe/europe_date_reported_one_deaths_weekly.html', + europe_date_reported=europe_date_reported, + page_data=page_data, + page_info=page_info) + + +@app.route('/europe/date_reported/cases_weekly/<int:europe_date_reported_id>/page/<int:page>') +@app.route('/europe/date_reported/cases_weekly/<int:europe_date_reported_id>') +def url_europe_date_reported_one_cases_weekly(europe_date_reported_id, page=1): + page_info = ApplicationPage('Europe', "date_reported") + europe_date_reported = EuropeDateReported.get_by_id(europe_date_reported_id) + page_data = EuropeData.find_by_date_reported_cases_weekly(europe_date_reported, page) + return render_template( + 'europe/europe_date_reported_one_cases_weekly.html', europe_date_reported=europe_date_reported, page_data=page_data, page_info=page_info) diff --git a/org/woehlke/covid19/europe/europe_model.py b/org/woehlke/covid19/europe/europe_model.py index ad75fd37ecd3bb1fb36e74705eb659f79f479935..9a11d4c7b95d19d86b248b3185725e8b549fb4c7 100644 --- a/org/woehlke/covid19/europe/europe_model.py +++ b/org/woehlke/covid19/europe/europe_model.py @@ -224,11 +224,37 @@ class EuropeData(db.Model): @classmethod def find_by_date_reported(cls, europe_date_reported, page): + #TODO: * Issue #43 /europe/date_reported return db.session.query(cls).filter( - cls.europe_date_reported_id == europe_date_reported.id).paginate(page, per_page=ITEMS_PER_PAGE) + cls.europe_date_reported_id == europe_date_reported.id)\ + .order_by(cls.notification_rate_per_100000_population_14days.desc())\ + .paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def find_by_date_reported_notification_rate(cls, europe_date_reported, page): + # TODO: * Issue #43 /europe/date_reported + return db.session.query(cls).filter( + cls.europe_date_reported_id == europe_date_reported.id) \ + .order_by(cls.notification_rate_per_100000_population_14days.desc()) \ + .paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def find_by_date_reported_deaths_weekly(cls, europe_date_reported, page): + # TODO: * Issue #43 /europe/date_reported + return db.session.query(cls).filter( + cls.europe_date_reported_id == europe_date_reported.id) \ + .order_by(cls.deaths_weekly.desc()) \ + .paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def find_by_date_reported_cases_weekly(cls, europe_date_reported, page): + # TODO: * Issue #43 /europe/date_reported + return db.session.query(cls).filter( + cls.europe_date_reported_id == europe_date_reported.id) \ + .order_by(cls.cases_weekly.desc()) \ + .paginate(page, per_page=ITEMS_PER_PAGE) @classmethod def find_by_country(cls, europe_country, page): return db.session.query(cls).filter( cls.europe_country_id == europe_country.id).paginate(page, per_page=ITEMS_PER_PAGE) - diff --git a/templates/europe/europe_date_reported_one_cases_weekly.html b/templates/europe/europe_date_reported_one_cases_weekly.html new file mode 100644 index 0000000000000000000000000000000000000000..8a2758da98a644d40d36b5d596bfaaa0f40cda41 --- /dev/null +++ b/templates/europe/europe_date_reported_one_cases_weekly.html @@ -0,0 +1,69 @@ +{% extends 'page_layout.html' %} + +{% block navigation_breadcrumb %} +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_europe.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_europe_date_reported_one_cases_weekly', + europe_date_reported_id=europe_date_reported.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_europe_date_reported_one_cases_weekly', + europe_date_reported_id=europe_date_reported.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_europe_date_reported_one_cases_weekly', + europe_date_reported_id=europe_date_reported.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'europe/fragment_europe_data_table.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/europe/europe_date_reported_one_deaths_weekly.html b/templates/europe/europe_date_reported_one_deaths_weekly.html new file mode 100644 index 0000000000000000000000000000000000000000..2971763924c12fb358ec5def456a1e3839fcf94d --- /dev/null +++ b/templates/europe/europe_date_reported_one_deaths_weekly.html @@ -0,0 +1,69 @@ +{% extends 'page_layout.html' %} + +{% block navigation_breadcrumb %} +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_europe.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_europe_date_reported_one_deaths_weekly', + europe_date_reported_id=europe_date_reported.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_europe_date_reported_one_deaths_weekly', + europe_date_reported_id=europe_date_reported.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_europe_date_reported_one_deaths_weekly', + europe_date_reported_id=europe_date_reported.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'europe/fragment_europe_data_table.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/europe/europe_date_reported_one_notification_rate.html b/templates/europe/europe_date_reported_one_notification_rate.html new file mode 100644 index 0000000000000000000000000000000000000000..e2e10047720ff59327517cf303b733afe206d6af --- /dev/null +++ b/templates/europe/europe_date_reported_one_notification_rate.html @@ -0,0 +1,69 @@ +{% extends 'page_layout.html' %} + +{% block navigation_breadcrumb %} +{% endblock %} + +{% block navigation_navtabs %} + {% include 'fragment_navtabs_europe.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_europe_date_reported_one_notification_rate', + europe_date_reported_id=europe_date_reported.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_europe_date_reported_one_notification_rate', + europe_date_reported_id=europe_date_reported.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_europe_date_reported_one_notification_rate', + europe_date_reported_id=europe_date_reported.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'europe/fragment_europe_data_table.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/europe/fragment_europe_data_table.html b/templates/europe/fragment_europe_data_table.html index 373a56eb108fedb41d7fe7d56d7cc70dfef6e934..4519fc4e66c408b2c9bfd5f548e5567ffd4fb41b 100644 --- a/templates/europe/fragment_europe_data_table.html +++ b/templates/europe/fragment_europe_data_table.html @@ -3,9 +3,27 @@ <tr> <th scope="col">date rep</th> <th scope="col">year_week</th> - <th scope="col">deaths weekly</th> - <th scope="col">cases weekly</th> - <th scope="col">notification rate per 100000 population 14days</th> + <th scope="col"> + <a href="{{ url_for( 'url_europe_date_reported_one_deaths_weekly', + europe_date_reported_id=europe_date_reported.id, + page=page_data.page) }}"> + deaths weekly + </a> + </th> + <th scope="col"> + <a href="{{ url_for( 'url_europe_date_reported_one_cases_weekly', + europe_date_reported_id=europe_date_reported.id, + page=page_data.page) }}"> + cases weekly + </a> + </th> + <th scope="col"> + <a href="{{ url_for( 'url_europe_date_reported_one_notification_rate', + europe_date_reported_id=europe_date_reported.id, + page=page_data.page) }}"> + notification rate per 100000 population 14days + </a> + </th> <th scope="col">countries and territories</th> <th scope="col">population data 2019</th> <th scope="col">geo id</th>