diff options
author | Andrea Lepori <aleporia@gmail.com> | 2023-07-27 12:51:22 +0200 |
---|---|---|
committer | Andrea Lepori <aleporia@gmail.com> | 2023-07-27 12:51:22 +0200 |
commit | 6062edc3e830421bfe84f01945ca5340f28fdd9e (patch) | |
tree | 763bf456f261dec2ded8ba42707b8964bc5cf5b9 | |
parent | user list and branca tansfer with new uc (diff) | |
download | scout-subs-6062edc3e830421bfe84f01945ca5340f28fdd9e.tar.gz scout-subs-6062edc3e830421bfe84f01945ca5340f28fdd9e.zip |
check complete data before doc creation
Diffstat (limited to '')
-rw-r--r-- | accounts/templates/accounts/user_edit.html | 9 | ||||
-rw-r--r-- | accounts/views.py | 8 | ||||
-rw-r--r-- | client/templates/client/index.html | 12 | ||||
-rw-r--r-- | client/views.py | 8 | ||||
-rw-r--r-- | version.txt | 2 |
5 files changed, 30 insertions, 9 deletions
diff --git a/accounts/templates/accounts/user_edit.html b/accounts/templates/accounts/user_edit.html index 44eae5b..6baf9bd 100644 --- a/accounts/templates/accounts/user_edit.html +++ b/accounts/templates/accounts/user_edit.html @@ -205,16 +205,19 @@ <h6>Scheda medica personale</h6> </div> <div class="input-field col s12"> - <input value="{{sickness}}" name="sickness" id="sickness" type="text" data-length="250"> + <input value="{{sickness}}" name="sickness" id="sickness" type="text" data-length="250" {{validation_dic.sickness|safe}}> <label for="sickness">Principali malattie avute</label> + <span class="helper-text" data-error="Campo richiesto"></span> </div> <div class="input-field col l8 s12"> - <input value="{{vaccine}}" name="vaccine" id="vaccine" type="text" data-length="250"> + <input value="{{vaccine}}" name="vaccine" id="vaccine" type="text" data-length="250" {{validation_dic.vaccine|safe}}> <label for="vaccine">Vacinazioni fatte</label> + <span class="helper-text" data-error="Campo richiesto"></span> </div> <div class="input-field col l4 s12"> + <input value="{{tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text" {{validation_dic.tetanus_date|safe}}> <label for="tetanus_date">Ultima vacinazione contro il tetano</label> - <input value="{{tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text" class="datepicker"> + <span class="helper-text" data-error="Campo richiesto"></span> </div> <div class="input-field col s12"> <input value="{{allergy}}" name="allergy" id="allergy" type="text" data-length="250"> diff --git a/accounts/views.py b/accounts/views.py index 59afbf8..47b66a2 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -549,17 +549,19 @@ def edit(request, code): missing_fields = False - if request.POST["birth_date"] == "" or request.POST["birth_date"] == "01 Gennaio 1970" or request.POST["birth_date"] == "None": + if request.POST["birth_date"] == "" or request.POST["birth_date"].lower() == "01 gennaio 1970" or request.POST["birth_date"] == "None" or request.POST["birth_date"] == "Giovedì 01 Gennaio 1970 00:00": validation_dic["birth_date"] = 'class="datepicker validate invalid" required="" aria-required="true"' missing_fields = True else: validation_dic["birth_date"] = 'class="datepicker validate" required="" aria-required="true"' - if request.POST["tetanus_date"] == "" or request.POST["tetanus_date"] == "01 Gennaio 1970" or request.POST["tetanus_date"] == "None": + if request.POST["tetanus_date"] == "" or request.POST["tetanus_date"].lower() == "01 gennaio 1970" or request.POST["tetanus_date"] == "None" or request.POST["tetanus_date"] == "Giovedì 01 Gennaio 1970 00:00": validation_dic["tetanus_date"] = 'class="datepicker validate invalid" required="" aria-required="true"' missing_fields = True + print("missing!!") else: validation_dic["tetanus_date"] = 'class="datepicker validate" required="" aria-required="true"' + print("not missing") for i in required_fields: if request.POST[i] == "": @@ -571,6 +573,8 @@ def edit(request, code): if missing_fields: errors.append("Alcuni campi richiesti non sono stati compilati") + print(validation_dic) + # check if user uploaded a file if "vac_certificate" in request.FILES: files = request.FILES.getlist('vac_certificate') 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 @@ <p style="text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: {{data.2}};">{{data.0.first_name}} {{data.0.last_name}}<a href="{% url "edit_user" code=data.0.code %}" class="btn-flat"><i class="material-icons">edit</i></a></p> <div style="font-size: 0.5em; line-height: normal;">{{data.0.born_date}}</div> </span> - <a id="add" class="btn-floating halfway-fab btn-large {{color}}" href="{% url 'create' code=data.0.code %}"><i class="material-icons">add</i></a> {% if data.1|length > 0 %} <ul class="collapsible"> {% for doc in data.1 %} @@ -420,13 +419,22 @@ </li> {% endfor %} </ul> -{% else %} +{% elif data.3 == False %} <div class="row"> <div class="col s12"> Nessun documento per questa persona </div> </div> {% endif %} +{% if data.3 %} +<div class="row"> + <div class="col s12"> + <p class="red lighten-1">I dati per questa persona non sono completi. Per poter creare una nuova iscrizione completare tutti i dati.</p> + </div> +</div> +{% else %} +<a id="add" class="btn-floating halfway-fab btn-large {{color}}" href="{% url 'create' code=data.0.code %}"><i class="material-icons">add</i></a> +{% endif %} </div> </div> </div> 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"] diff --git a/version.txt b/version.txt index b110dc6..c7d2167 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.6 -rev=33 +rev=34 |