From 0eb9705e8c42a46f902485e51a6258db7ca37256 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Thu, 15 Sep 2022 10:02:39 +0200 Subject: switch tab on the profile based on missing fields --- accounts/templates/accounts/index.html | 2 +- accounts/views.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'accounts') diff --git a/accounts/templates/accounts/index.html b/accounts/templates/accounts/index.html index 563de89..8ce5990 100644 --- a/accounts/templates/accounts/index.html +++ b/accounts/templates/accounts/index.html @@ -10,7 +10,7 @@ diff --git a/accounts/views.py b/accounts/views.py index 959fa28..88bd141 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -377,6 +377,7 @@ def personal_wrapper(request, errors): context = {} ok_message = "" personal_active = "active" + medic_active = "" settings_active = "" # additional user information usercode = UserCode.objects.filter(user=request.user)[0] @@ -394,6 +395,8 @@ def personal_wrapper(request, errors): # variables for validation validation_dic = {} required_fields = ["first_name", "last_name", "email", "parent_name", "via", "cap", "country", "nationality", "phone", "avs_number", "emer_name", "emer_relative", "cell_phone", "address", "health_care", "injuries", "rc", "medic_name", "medic_phone", "medic_address"] + personal_fields = ["first_name", "last_name", "email", "parent_name", "via", "cap", "country", "nationality", "phone", "avs_number"] + medic_fields = ["emer_name", "emer_relative", "cell_phone", "address", "health_care", "injuries", "rc", "medic_name", "medic_phone", "medic_address"] if request.method == "POST": # requested download @@ -505,21 +508,29 @@ def personal_wrapper(request, errors): medic.save() missing_fields = False + missing_personal_field = False + if request.POST["birth_date"] == "" or request.POST["birth_date"] == "01 Gennaio 1970" or request.POST["birth_date"] == "None": validation_dic["birth_date"] = 'class="datepicker validate invalid" required="" aria-required="true"' missing_fields = True + missing_personal_field = True else: validation_dic["birth_date"] = 'class="datepicker validate" required="" aria-required="true"' for i in required_fields: if request.POST[i] == "": missing_fields = True + if i in personal_fields: + missing_personal_field = True validation_dic[i] = 'class="validate invalid" required="" aria-required="true"' else: validation_dic[i] = 'class="validate" required="" aria-required="true"' if missing_fields: errors.append("Alcuni campi richiesti non sono stati compilati") + if not missing_personal_field: + personal_active = "" + medic_active = "active" # if "branca" in request.POST: # if request.POST["branca"] != "": @@ -735,8 +746,9 @@ def personal_wrapper(request, errors): 'midata_user': midata_user, 'midata_disable': midata_disable, 'usable_password': usable_password, - 'settings_active': settings_active, 'personal_active': personal_active, + 'medic_active': medic_active, + 'settings_active': settings_active, 'midata_enabled': MIDATA_ENABLED, 'home_tooltip': home_tooltip, } -- cgit v1.2.1