From be3686074da9c00faf6ad183cc4494e1130100e6 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Tue, 4 Oct 2022 18:37:35 +0200 Subject: edit data export format to comply with midata --- server/views.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/views.py b/server/views.py index 12b79e9..1fb80ac 100644 --- a/server/views.py +++ b/server/views.py @@ -1701,7 +1701,8 @@ def data_request(request): data = ", ".join(users_email) context["data"] = data elif request.POST["request"] == "data_user": - users = User.objects.filter(groups__name=parent_group) + perm = Permission.objects.get(codename="approved") + users = User.objects.filter(groups__name=parent_group, user_permissions=perm) # get time for filename current_time = datetime.strftime(datetime.now(), "%H_%M__%d_%m_%y") @@ -1712,10 +1713,20 @@ def data_request(request): writer = csv.writer(response) # csv header - writer.writerow(["Codice", "Nome", "Cognome", "Email", "Nome dei genitori", "Via", "CAP", "Comune", "Nazionalita", "Data di nascita", "Telefono di casa", "Telefono", "Scuola", "Anno scolastico", "Numero AVS"]) + writer.writerow(["Codice", "Nome", "Cognome", "Email", "Nome dei genitori", "Indirizzo", "NAP", "Luogo", "Nazionalita", "Nazionalità secondo G+S", "Data di nascita", "numero di telefono Altro", "numero di telefono Cellulare", "Scuola", "Classe scolastica", "Numero AVS"]) for user in users: usercode = UserCode.objects.filter(user=user)[0] + nationality = usercode.nationality + + nat_gs = "" + if "svizzera" in nationality.lower(): + nat_gs = "CH" + elif "ch" == nationality.lower(): + nat_gs = "CH" + else: + nat_gs = "DIV" + writer.writerow([ "U"+str(usercode.code), user.first_name, @@ -1726,6 +1737,7 @@ def data_request(request): usercode.cap, usercode.country, usercode.nationality, + nat_gs, usercode.born_date, usercode.home_phone, usercode.phone, @@ -1737,7 +1749,8 @@ def data_request(request): return response elif request.POST["request"] == "data_user_medic": - users = User.objects.filter(groups__name=parent_group) + perm = Permission.objects.get(codename="approved") + users = User.objects.filter(groups__name=parent_group, user_permissions=perm) # get time for filename current_time = datetime.strftime(datetime.now(), "%H_%M__%d_%m_%y") @@ -1748,11 +1761,20 @@ def data_request(request): writer = csv.writer(response) # csv header - writer.writerow(["Codice", "Nome", "Cognome", "Email", "Nome dei genitori", "Via", "CAP", "Comune", "Nazionalita", "Data di nascita", "Telefono di casa", "Telefono", "Scuola", "Anno scolastico", "Numero AVS", "Contatto d'emergenza", "Parentela del contatto", "Telefono d'emergenza", "Cellulare emergenza", "Indirizzo completo emergenza", "Cassa malati", "Ass. Infortuni", "Ass. RC", "Socio REGA", "Nome del medico", "Telefono medico", "Indirizzo medico", "Malattie", "Vacinazioni", "Data antitetanica", "Allergie", "Assume medicamenti", "Medicamenti", "Informazioni particolari", "Informazioni"]) + writer.writerow(["Codice", "Nome", "Cognome", "Email", "Nome dei genitori", "Indirizzo", "NAP", "Luogo", "Nazionalita", "Nazionalità secondo G+S", "Data di nascita", "numero di telefono Altro", "numero di telefono Cellulare", "Scuola", "Classe scolastica", "Numero AVS", "Contatto d'emergenza", "Parentela del contatto", "Telefono d'emergenza", "Cellulare emergenza", "Indirizzo completo emergenza", "Cassa malati", "Ass. Infortuni", "Ass. RC", "Socio REGA", "Nome del medico", "Telefono medico", "Indirizzo medico", "Malattie", "Vacinazioni", "Data antitetanica", "Allergie", "Assume medicamenti", "Medicamenti", "Informazioni particolari", "Informazioni"]) for user in users: usercode = UserCode.objects.filter(user=user)[0] medic = usercode.medic + + nat_gs = "" + if "svizzera" in nationality.lower(): + nat_gs = "CH" + elif "ch" == nationality.lower(): + nat_gs = "CH" + else: + nat_gs = "DIV" + writer.writerow([ "U"+str(usercode.code), user.first_name, @@ -1763,6 +1785,7 @@ def data_request(request): usercode.cap, usercode.country, usercode.nationality, + nat_gs, usercode.born_date, usercode.home_phone, usercode.phone, -- cgit v1.2.1 From d0dbd52f34ee58212909a829343ea7d7bdc3916f Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Mon, 21 Nov 2022 22:11:27 +0100 Subject: fix incorrect group check for permissions --- server/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/views.py b/server/views.py index 1fb80ac..fb4af8a 100644 --- a/server/views.py +++ b/server/views.py @@ -1651,10 +1651,11 @@ def docpreview(request): # get document document = Document.objects.filter(code=code)[0] + doc_group = document.group.name parent_group = document.user.groups.values_list('name', flat=True)[0] # user has not permission to view document - if parent_group not in groups: + if doc_group not in groups: return # prepare images in base64 -- cgit v1.2.1 From 22872ed11e8d9b61d09a5b4061f50279681d21c2 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Thu, 29 Dec 2022 10:58:09 +0100 Subject: fix wrong selection, doclist quick filters --- server/templates/server/doc_list.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html index 45ea6e0..023cf54 100644 --- a/server/templates/server/doc_list.html +++ b/server/templates/server/doc_list.html @@ -619,7 +619,9 @@ $('#select-all').click(function(event) { if(this.checked) { // Iterate each checkbox $('.allselect').each(function() { - this.checked = true; + if (!this.hidden) { + this.checked = true; + } }); } else { $('.allselect').each(function() { @@ -667,9 +669,11 @@ function filterResults(group_name) { for (i = 0; i < items.length; i++) { var a = items[i].children[0]; + var checkBox = items[i].children[1].children[0].children[0]; var txtValue = a.value; if (txtValue == group_name) { items[i].style.display = action; + checkBox.hidden = (action == "none"); } } } -- cgit v1.2.1 From d17b448a9c070c0d4702a90290036aa477fddfd6 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Thu, 29 Dec 2022 11:02:49 +0100 Subject: fix quick select for readonly doclist --- server/templates/server/doc_list_readonly.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/templates/server/doc_list_readonly.html b/server/templates/server/doc_list_readonly.html index ac1ae6d..c29fb74 100644 --- a/server/templates/server/doc_list_readonly.html +++ b/server/templates/server/doc_list_readonly.html @@ -600,7 +600,9 @@ $('#select-all').click(function(event) { if(this.checked) { // Iterate each checkbox $('.allselect').each(function() { - this.checked = true; + if (!this.hidden) { + this.checked = true; + } }); } else { $('.allselect').each(function() { @@ -648,9 +650,11 @@ function filterResults(group_name) { for (i = 0; i < items.length; i++) { var a = items[i].children[0]; + var checkBox = items[i].children[1].children[0].children[0]; var txtValue = a.value; if (txtValue == group_name) { items[i].style.display = action; + checkBox.hidden = (action == "none"); } } } -- cgit v1.2.1 From 37bfbd7dcdd2542228984b1f8161fd94860750f7 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Thu, 29 Dec 2022 11:16:40 +0100 Subject: remove unarchive, enable archive unapproved docs --- server/templates/server/doc_list.html | 3 ++- server/views.py | 30 +++++++++++++----------------- 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'server') diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html index 023cf54..06c8893 100644 --- a/server/templates/server/doc_list.html +++ b/server/templates/server/doc_list.html @@ -17,7 +17,7 @@
  • archive
  • -
  • unarchive
  • +
  • file_download
  • {% if settings.DEBUG %}
  • checkDEBUG
  • @@ -38,6 +38,7 @@ diff --git a/server/views.py b/server/views.py index fb4af8a..89c66b2 100644 --- a/server/views.py +++ b/server/views.py @@ -1118,23 +1118,19 @@ def doclist(request): docc.status = 'ok' docc.save() elif request.POST["action"] == 'archive': - if docc.status == 'ok': - docc.status = 'archive' - if docc.medical_data: - docc.medical_data.delete() - docc.medical_data.save() - docc.medical_data = None - docc.save() - else: - error = True - error_text = "Non puoi archiviare un documento non approvato" - elif request.POST["action"] == 'unarchive': - if docc.status == 'archive': - docc.status = 'ok' - docc.save() - else: - error = True - error_text = "Non puoi dearchiviare un documento non archiviato" + docc.status = 'archive' + if docc.medical_data: + docc.medical_data.delete() + docc.medical_data.save() + docc.medical_data = None + docc.save() + #elif request.POST["action"] == 'unarchive': + # if docc.status == 'archive': + # docc.status = 'ok' + # docc.save() + # else: + # error = True + # error_text = "Non puoi dearchiviare un documento non archiviato" # get filter values hidden = "filter_hidden" in request.POST -- cgit v1.2.1