From c730af39f2ecdbd100662bcdfd14dfda1802915e Mon Sep 17 00:00:00 2001
From: zakhy
Date: Sun, 16 Mar 2025 10:37:46 +0700
Subject: [PATCH] =?UTF-8?q?=20=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D0=BA=D0=B0=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D0=B0=20+=20?=
=?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/report/service.py | 9 ++++-----
app/report/templates/report/report.html | 14 ++++++++------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/app/report/service.py b/app/report/service.py
index fd1a325..74f1ba5 100644
--- a/app/report/service.py
+++ b/app/report/service.py
@@ -78,18 +78,17 @@ class ReportService:
for cheque in cheques:
month_key = cheque.uploaded_at.strftime('%Y-%m')
if month_key not in cheques_by_month or \
- cheque.uploaded_at > cheques_by_month[
- month_key].uploaded_at:
+ cheque.uploaded_at > cheques_by_month[month_key].uploaded_at:
cheques_by_month[month_key] = cheque
- latest_contract = Contract.objects.filter(user=user).latest(
- 'uploaded_at')
+ latest_contract = Contract.objects.filter(user=user).order_by(
+ 'uploaded_at').last()
user_dict = {
"id": user.id,
"name": user.get_name(),
"visits_count": user_circles_count,
- "contract": f'{host_url}{latest_contract.file.url}',
+ "contract": f'{host_url}{latest_contract.file.url}' if user_has_contract else None,
"cheques": [
{
"month": f"{months_names[cheque.uploaded_at.strftime('%m')]} "
diff --git a/app/report/templates/report/report.html b/app/report/templates/report/report.html
index 1d3000e..3d8dd8f 100644
--- a/app/report/templates/report/report.html
+++ b/app/report/templates/report/report.html
@@ -100,18 +100,20 @@
Количество посещений:
{{ not_accessed.visits_count }}/{{ required_count }}
- Договор
+ {% if not_accessed.contract %}
+ Договор
+ {% endif %}
{% for cheque in not_accessed.cheques %}
Чек
за {{ cheque.month }}
{% endfor %}
Причины отказа:
- {% for reason in not_accessed.reasons %}
- -
- {{ reason }}
-
- {% endfor %}
+ {% for reason in not_accessed.reasons %}
+ -
+ {{ reason }}
+
+ {% endfor %}