aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2022-09-15 10:02:39 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2022-09-15 10:02:39 +0200
commit0eb9705e8c42a46f902485e51a6258db7ca37256 (patch)
treea72b841de251bc7a540b7bcc9f1c2dc712707f53
parentremove unused/useless code (diff)
downloadscout-subs-0eb9705e8c42a46f902485e51a6258db7ca37256.tar.gz
scout-subs-0eb9705e8c42a46f902485e51a6258db7ca37256.zip
switch tab on the profile based on missing fields
Diffstat (limited to '')
-rw-r--r--accounts/templates/accounts/index.html2
-rw-r--r--accounts/views.py14
-rw-r--r--version.txt2
3 files changed, 15 insertions, 3 deletions
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 @@
<div class="nav-content {{color}}">
<ul class="tabs tabs-transparent">
<li class="tab"><a class="{{personal_active}}" href="#personal">Info Personali</a></li>
- <li class="tab"><a href="#medic">Info Mediche</a></li>
+ <li class="tab"><a class="{{medic_active}}" href="#medic">Info Mediche</a></li>
<li class="tab"><a class="{{settings_active}}" href="#settings">Impostazioni</a></li>
</ul>
</div>
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,
}
diff --git a/version.txt b/version.txt
index 13e827c..9b78346 100644
--- a/version.txt
+++ b/version.txt
@@ -1,2 +1,2 @@
version=0.6
-rev=5
+rev=6