diff --git a/app.py b/app.py index 5c7e2deba9357b241c2681f8cb38f0462cb37aee..471f8ddb4c60129be4f8b3fb79f44ef1fbcb5b0f 100644 --- a/app.py +++ b/app.py @@ -288,7 +288,7 @@ def url_europe_date_reported(page=1): def url_europe_date_reported_one(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_data = EuropeData.find_by_date_reported(europe_date_reported, page) return render_template( 'europe/europe_date_reported_one.html', europe_date_reported=europe_date_reported, @@ -307,9 +307,9 @@ def url_europe_continent(page=1): page_info=page_info) -@app.route('/europe/country/page/<int:page>') -@app.route('/europe/country') -def url_europe_country(page=1): +@app.route('/europe/country/all/page/<int:page>') +@app.route('/europe/country/all') +def url_europe_country_all(page=1): page_info = ApplicationPage('Europe', "country") page_data = EuropeCountry.get_all_as_page(page) return render_template( @@ -318,6 +318,19 @@ def url_europe_country(page=1): page_info=page_info) +@app.route('/europe/country/<int:country_id>/page/<int:page>') +@app.route('/europe/country/<int:country_id>') +def url_europe_country_one(country_id, page=1): + page_info = ApplicationPage('Europe', "country") + europe_country = EuropeCountry.get_by_id(country_id) + page_data = EuropeData.find_by_country(europe_country, page) + return render_template( + 'europe/europe_country_one.html', + europe_country=europe_country, + page_data=page_data, + page_info=page_info) + + @app.route('/europe/data/page/<int:page>') @app.route('/europe/data') def url_europe_data(page=1): diff --git a/org/woehlke/covid19/europe/europe_model.py b/org/woehlke/covid19/europe/europe_model.py index fa815a1c6a127cbecea749ce27c482cf3ebfa336..a77d8025515307309f2494276c251e047328e0d7 100644 --- a/org/woehlke/covid19/europe/europe_model.py +++ b/org/woehlke/covid19/europe/europe_model.py @@ -213,7 +213,12 @@ class EuropeData(db.Model): return db.session.query(cls).filter(cls.id == other_id).one() @classmethod - def find_by_date_reported(cls, europe_date_reported): + def find_by_date_reported(cls, europe_date_reported, page): + return db.session.query(cls).filter( + cls.europe_date_reported_id == europe_date_reported.id).paginate(page, per_page=ITEMS_PER_PAGE) + + @classmethod + def find_by_country(cls, europe_country, page): return db.session.query(cls).filter( - cls.europe_date_reported_id == europe_date_reported.id).all() + cls.europe_country_id == europe_country.id).paginate(page, per_page=ITEMS_PER_PAGE) diff --git a/templates/europe/europe_country_all.html b/templates/europe/europe_country_all.html index 88d4e8f5d5a70f01a4b9da567af8b6af790d0205..7427d42a71c6308653e1cfc44501191f17424db7 100644 --- a/templates/europe/europe_country_all.html +++ b/templates/europe/europe_country_all.html @@ -21,7 +21,7 @@ {% if page_data.has_prev %} <li class="page-item"> <a class="page-link" - href="{{ url_for( 'url_europe_country', page=page_data.prev_num) }}"> + href="{{ url_for( 'url_europe_country_all', page=page_data.prev_num) }}"> Previous </a> </li> @@ -31,7 +31,7 @@ {% if page_num != page_data.page %} <li class="page-item"> <a class="page-link" - href="{{ url_for( 'url_europe_country', page=page_num) }}"> + href="{{ url_for( 'url_europe_country_all', page=page_num) }}"> {{ page_num }} </a> </li> @@ -49,7 +49,7 @@ {% if page_data.has_next %} <li class="page-item"> <a class="page-link" - href="{{ url_for( 'url_europe_country', page=page_data.next_num) }}"> + href="{{ url_for( 'url_europe_country_all', page=page_data.next_num) }}"> Next </a> </li> @@ -70,11 +70,16 @@ <tbody> {% for europe_country in page_data.items %} <tr> - <td>{{ europe_country.countries_and_territories }}</td> + <td> + <a href="/europe/country/{{ europe_country.id }}"> + {{ europe_country.countries_and_territories }}</a></td> <td>{{ europe_country.pop_data_2019 }}</td> - <td>{{ europe_country.geo_id }}</td> - <td>{{ europe_country.country_territory_code }}</td> - <td>{{ europe_country.continent.continent_exp }}</td> + <td><a href="/europe/country/{{ europe_country.id }}"> + {{ europe_country.geo_id }}</a></td> + <td><a href="/europe/country/{{ europe_country.id }}"> + {{ europe_country.country_territory_code }}</a></td> + <td><a href="/europe/continent/{{ europe_country.continent.id }}"> + {{ europe_country.continent.continent_exp }}</a></td> </tr> {% endfor %} </tbody> diff --git a/templates/europe/europe_country_one.html b/templates/europe/europe_country_one.html new file mode 100644 index 0000000000000000000000000000000000000000..53aa7c4b254204fca6b1247b755a70e252864538 --- /dev/null +++ b/templates/europe/europe_country_one.html @@ -0,0 +1,66 @@ +{% extends 'page_layout.html' %} + +{% 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_country_one', + country_id=europe_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_europe_country_one', + country_id=europe_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_europe_country_one', + country_id=europe_country.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'europe/europe_data_table.html' %} + +{% endblock %} + + +{% block footer_container %} + <div> + {% for error in errors %} + <h4>{{ error }}</h4> + {% endfor %} + </div> +{% endblock %} diff --git a/templates/europe/europe_data_table.html b/templates/europe/europe_data_table.html new file mode 100644 index 0000000000000000000000000000000000000000..1f85f333b09610777f0ae9c059ae596348acd77d --- /dev/null +++ b/templates/europe/europe_data_table.html @@ -0,0 +1,37 @@ + <table class="table table-hover table-striped"> + <thead> + <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">countries and territories</th> + <th scope="col">pop data 2019</th> + <th scope="col">geo id</th> + <th scope="col">country territory code</th> + <th scope="col">continent</th> + </tr> + </thead> + <tbody> + {% for europe_data in page_data.items %} + <tr> + <th>{{ europe_data.europe_date_reported.date_rep }}</th> + <td><a href="/europe/date_reported/{{ europe_data.europe_date_reported.id }}"> + {{ europe_data.europe_date_reported.year_week }}</a></td> + <td>{{ europe_data.deaths_weekly }}</td> + <td>{{ europe_data.cases_weekly }}</td> + <td>{{ europe_data.notification_rate_per_100000_population_14days }}</td> + <td><a href="/europe/country/{{ europe_data.europe_country.id }}"> + {{ europe_data.europe_country.countries_and_territories }}</a></td> + <td>{{ europe_data.europe_country.pop_data_2019 }}</td> + <td><a href="/europe/country/{{ europe_data.europe_country.id }}"> + {{ europe_data.europe_country.geo_id }}</a></td> + <td><a href="/europe/country/{{ europe_data.europe_country.id }}"> + {{ europe_data.europe_country.country_territory_code }}</a></td> + <td><a href="/europe/continent/{{ europe_data.europe_country.continent.id }}"> + {{ europe_data.europe_country.continent.continent_exp }}</a></td> + </tr> + {% endfor %} + </tbody> + </table> \ No newline at end of file diff --git a/templates/europe/europe_date_reported_one.html b/templates/europe/europe_date_reported_one.html index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f34943d5e9cd96b8571eddedfcfca00cede96127 100644 --- a/templates/europe/europe_date_reported_one.html +++ b/templates/europe/europe_date_reported_one.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', + 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', + 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', + europe_date_reported_id=europe_date_reported.id, page=page_data.next_num) }}"> + Next + </a> + </li> + {% endif %} + </ul> + {% endif %} + + {% include 'europe/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