From d96ec671fc0e0dbdcc4f0d7d99e2d0b64bbf0ffe Mon Sep 17 00:00:00 2001
From: thomaswoehlke <thomas.woehlke@gmail.com>
Date: Mon, 18 Jan 2021 18:52:54 +0100
Subject: [PATCH] ### 0.0.8 Release * Fixed #13 /who/imported/ * Fixed #14
 /europe/imported/ * Fixed #15 /who/update: Download * Fixed #16 /who/update:
 Import File to DB * Issue #17 /who/update: Update DB * Issue #3 ORM: 3NF for
 ecdc_europa_data_import * Issue #4 data update for 3NF
 ecdc_europa_data_import

---
 etc/TODO.md                              |  3 +-
 templates/fragment_pagination.html       | 43 ++++++++++++++++++++++
 templates/layout.html                    | 17 +++++----
 templates/who/who_country_all.html       |  2 ++
 templates/who/who_date_reported_all.html |  2 ++
 templates/who/who_date_reported_one.html |  2 ++
 templates/who/who_imported.html          |  2 ++
 templates/who/who_region_all.html        |  2 ++
 templates/who/who_region_countries.html  |  2 ++
 templates/who/who_region_country.html    | 45 +++++++-----------------
 10 files changed, 80 insertions(+), 40 deletions(-)
 create mode 100644 templates/fragment_pagination.html

diff --git a/etc/TODO.md b/etc/TODO.md
index 24a245c1..89d2a13b 100644
--- a/etc/TODO.md
+++ b/etc/TODO.md
@@ -5,4 +5,5 @@
 * https://www.linode.com/docs/guides/task-queue-celery-rabbitmq/
 * https://suzannewang.com/celery-rabbitmq-tutorial/
 
-
+## Jinja
+* https://jinja.palletsprojects.com/en/2.11.x/templates/
diff --git a/templates/fragment_pagination.html b/templates/fragment_pagination.html
new file mode 100644
index 00000000..e54202b7
--- /dev/null
+++ b/templates/fragment_pagination.html
@@ -0,0 +1,43 @@
+{% macro pagination_for_url( url_for_pagination ) -%}
+                <!-- previous page -->
+                <ul class="pagination">
+                    {% if page_data.has_prev %}
+                    <li class="page-item">
+                        <a class="page-link"
+                           href="{{ url_for( url_for_pagination, country_id=who_country.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( url_for_pagination, 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 %}
+                    <!-- next page -->
+                    {% if page_data.has_next %}
+                    <li class="page-item">
+                        <a class="page-link"
+                           href="{{ url_for( url_for_pagination, country_id=who_country.id, page=page_data.next_num) }}">
+                            Next
+                        </a>
+                    </li>
+                    {% endif %}
+                </ul>
+            {%- endmacro %}
\ No newline at end of file
diff --git a/templates/layout.html b/templates/layout.html
index 12a19b08..5fb0b177 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -14,24 +14,29 @@
     <title>{{page_info.title}}</title>
     <style>
         .pagination-page-info {
-            padding: .6em;
-            padding-left: 0;
+            padding: .6em .6em .6em 0em;
+            /* padding-left: 0; */
             width: 40em;
-            margin: .5em;
-            margin-left: 0;
+            margin: .5em .5em .5em 0em;
+            /*margin-left: 0;*/
             font-size: 12px;
         }
         .pagination-page-info b {
             color: black;
             background: #6aa6ed;
-            padding-left: 2px;
-            padding: .1em .25em;
+            /*padding-left: 2px;*/
+            padding: .1em .25em .1em .25em;
             font-size: 150%;
         }
         .jumbotron {
             padding: 1rem 1rem;
             margin-bottom: 1rem;
         }
+        .my-page-item-ellipsis-page-link {
+            white-space: nowrap;
+            overflow: hidden;
+            text-overflow: ellipsis;
+        }
     </style>
 </head>
 <body>
diff --git a/templates/who/who_country_all.html b/templates/who/who_country_all.html
index 4d665786..55f1d096 100644
--- a/templates/who/who_country_all.html
+++ b/templates/who/who_country_all.html
@@ -1,5 +1,7 @@
 {% extends 'layout.html' %}
 
+{% include 'fragment_pagination.html' %}
+
 {% block navigation_breadcrumb %}
     <nav aria-label="breadcrumb">
         <ol class="breadcrumb">
diff --git a/templates/who/who_date_reported_all.html b/templates/who/who_date_reported_all.html
index 7830d007..fc0bd104 100644
--- a/templates/who/who_date_reported_all.html
+++ b/templates/who/who_date_reported_all.html
@@ -1,5 +1,7 @@
 {% extends 'layout.html' %}
 
+{% include 'fragment_pagination.html' %}
+
 {% block navigation_breadcrumb %}
     <nav aria-label="breadcrumb">
         <ol class="breadcrumb">
diff --git a/templates/who/who_date_reported_one.html b/templates/who/who_date_reported_one.html
index f8df7c0c..e215ebdc 100644
--- a/templates/who/who_date_reported_one.html
+++ b/templates/who/who_date_reported_one.html
@@ -1,5 +1,7 @@
 {% extends 'layout.html' %}
 
+{% include 'fragment_pagination.html' %}
+
 {% block navigation_breadcrumb %}
     <nav aria-label="breadcrumb">
         <ol class="breadcrumb">
diff --git a/templates/who/who_imported.html b/templates/who/who_imported.html
index a9618e12..e87f3082 100644
--- a/templates/who/who_imported.html
+++ b/templates/who/who_imported.html
@@ -1,5 +1,7 @@
 {% extends 'layout.html' %}
 
+{% include 'fragment_pagination.html' %}
+
 {% block navigation_breadcrumb %}
 
 {% endblock %}
diff --git a/templates/who/who_region_all.html b/templates/who/who_region_all.html
index ae7d7fb1..2e26937e 100644
--- a/templates/who/who_region_all.html
+++ b/templates/who/who_region_all.html
@@ -1,5 +1,7 @@
 {% extends 'layout.html' %}
 
+{% include 'fragment_pagination.html' %}
+
 {% block navigation_breadcrumb %}
     <nav aria-label="breadcrumb">
         <ol class="breadcrumb">
diff --git a/templates/who/who_region_countries.html b/templates/who/who_region_countries.html
index de979be0..71bb6c57 100644
--- a/templates/who/who_region_countries.html
+++ b/templates/who/who_region_countries.html
@@ -1,5 +1,7 @@
 {% extends 'layout.html' %}
 
+{% include 'fragment_pagination.html' %}
+
 {% block navigation_breadcrumb %}
     <nav aria-label="breadcrumb">
         <ol class="breadcrumb">
diff --git a/templates/who/who_region_country.html b/templates/who/who_region_country.html
index 79fa117b..ddfc9839 100644
--- a/templates/who/who_region_country.html
+++ b/templates/who/who_region_country.html
@@ -1,5 +1,7 @@
 {% extends 'layout.html' %}
 
+{% include 'fragment_pagination.html' %}
+
 {% block navigation_breadcrumb %}
     <nav aria-label="breadcrumb">
         <ol class="breadcrumb">
@@ -52,6 +54,8 @@
         </ul>
     {% endif %}
 
+    {{ pagination_for_url(url_for_pagination) }}
+
     <table class="table table-hover table-striped">
         <thead>
         <tr>
@@ -60,54 +64,29 @@
             <th scope="col">cases_new</th>
             <th scope="col">deaths_cumulative</th>
             <th scope="col">cases_cumulative</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>
-                <td>{{ who_global_data.date_reported }}</td>
+                <th><a href="/who/date_reported/{{ who_global_data.date_reported_id }}">{{ who_global_data.date_reported }}</a></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>{{ who_global_data.country.country_code }}</td>
+                <td>{{ who_global_data.country.country }}</td>
+                <td>{{ who_global_data.country.region.region }}</td>
             </tr>
         {% endfor %}
         </tbody>
     </table>
 
+    {{ pagination_for_url(url_for_pagination) }}
 
-     <!-- previous page -->
-    <ul class="pagination">
-    {% if page_data.has_prev %}
-    <li class="page-item">
-        <a class="page-link" href="{{ url_for('url_who_region_country', country_id=who_country.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('url_who_region_country',  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" style="white-space; nowrap; overflow: hidden; text-overflow: ellipsis">…</span>
-           </li>
-       {% endif %}
-    {% endfor %}
-    <!-- next page -->
-    {% if page_data.has_next %}
-    <li class="page-item">
-        <a class="page-link" href="{{ url_for('url_who_region_country', country_id=who_country.id , page=page_data.next_num) }}">Next</a>
-    </li>
-    {% endif %}
-    </ul>
 {% endblock %}
 
 
-- 
GitLab