From 6062edc3e830421bfe84f01945ca5340f28fdd9e Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Thu, 27 Jul 2023 12:51:22 +0200 Subject: check complete data before doc creation --- client/templates/client/index.html | 12 ++++++++++-- client/views.py | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/templates/client/index.html b/client/templates/client/index.html index d0fcc9b..8086ed5 100644 --- a/client/templates/client/index.html +++ b/client/templates/client/index.html @@ -38,7 +38,6 @@

{{data.0.first_name}} {{data.0.last_name}}edit

{{data.0.born_date}}
- add {% if data.1|length > 0 %} -{% else %} +{% elif data.3 == False %}
Nessun documento per questa persona
+{% endif %} +{% if data.3 %} +
+
+

I dati per questa persona non sono completi. Per poter creare una nuova iscrizione completare tutti i dati.

+
+
+{% else %} +add {% endif %} diff --git a/client/views.py b/client/views.py index 2ed0c6b..b0029f0 100644 --- a/client/views.py +++ b/client/views.py @@ -12,6 +12,7 @@ from django.conf import settings from io import BytesIO import pdfkit from datetime import datetime +import datetime as dt import pytz from random import randint @@ -106,7 +107,12 @@ def index(request): color = "black" else: color = color_mapping[uc.branca.name] - docs.append([uc, documents, color]) + required_fields = ["first_name", "last_name", "parent_name", "via", "cap", "country", "nationality", "phone", "avs_number", "born_date"] + required_medic_fields = ["emer_name", "emer_relative", "cell_phone", "address", "health_care", "injuries", "rc", "medic_name", "medic_phone", "medic_address", "sickness", "vaccine", "tetanus_date"] + data = [uc.__dict__[key] for key in required_fields] + data += [uc.medic.__dict__[key] for key in required_medic_fields] + invalid_flag = ("" in data) or (None in data) or (dt.date(1970, 1, 1) in data) + docs.append([uc, documents, color, invalid_flag]) # show only docs of the user and non archived vac_file = ["/server/media/", "/vac_certificate/doc"] -- cgit v1.2.1