From 5f88a4f2977bbf13959065dff094af3986a50f61 Mon Sep 17 00:00:00 2001 From: Kiselev Igor Date: Thu, 13 May 2021 17:51:28 +0300 Subject: [PATCH 1/2] Fixed statistic view date bug --- main/templates/pages/statistic.html | 4 ++++ main/views.py | 1 + 2 files changed, 5 insertions(+) diff --git a/main/templates/pages/statistic.html b/main/templates/pages/statistic.html index b467250..202d8f2 100644 --- a/main/templates/pages/statistic.html +++ b/main/templates/pages/statistic.html @@ -88,7 +88,11 @@   {% for date in log_stats.keys %} + {% if interval == 'days' %} {{ date | date:'d.m' }} + {% else %} + {{ date }} + {% endif %} {% endfor %} diff --git a/main/views.py b/main/views.py index 69fdd92..5c02a65 100644 --- a/main/views.py +++ b/main/views.py @@ -381,6 +381,7 @@ def statistic_page(request: WSGIRequest) -> HttpResponse: context['errors'] = data.errors if data.warnings: context['warnings'] = data.warnings + context['interval'] = data.interval context['log_stats'] = stats if not context['errors'] else None elif request.method == 'GET': form = StatisticForm() From 23eb2bf2ecf9041590a7d5994e94844c67439646 Mon Sep 17 00:00:00 2001 From: Andrew Smirnov Date: Thu, 13 May 2021 19:55:21 +0300 Subject: [PATCH 2/2] Fix month display on statistics page --- main/extra_func.py | 2 +- main/templates/pages/statistic.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/extra_func.py b/main/extra_func.py index c41625a..1aade32 100644 --- a/main/extra_func.py +++ b/main/extra_func.py @@ -373,7 +373,7 @@ class StatisticData: for key, value in stat.items(): current_month_start = max(self.start_date, date(year=key.year, month=key.month, day=1)) current_month_end = min(self.end_date, last_day_of_month(date(year=key.year, month=key.month, day=1))) - index = ' - '.join([str(current_month_start), str(current_month_end)]) + index = (current_month_start, current_month_end) if new_stat.get(index): new_stat[index] += value else: diff --git a/main/templates/pages/statistic.html b/main/templates/pages/statistic.html index 202d8f2..87bea80 100644 --- a/main/templates/pages/statistic.html +++ b/main/templates/pages/statistic.html @@ -91,7 +91,7 @@ {% if interval == 'days' %} {{ date | date:'d.m' }} {% else %} - {{ date }} + {{ date.1 | date:'F' }} {% endif %} {% endfor %}