From 0dfed66987e704d757725257d4b2a5e55b72ee5e Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Sun, 21 Jun 2020 15:38:44 +0200 Subject: Filter improve, missing chips and date --- server/templates/server/doc_list.html | 56 ++++++++++++++++++++++++++--------- server/views.py | 49 ++++++++++++++++++++++++++---- 2 files changed, 85 insertions(+), 20 deletions(-) diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html index 730837c..331a3d5 100644 --- a/server/templates/server/doc_list.html +++ b/server/templates/server/doc_list.html @@ -61,7 +61,7 @@
@@ -73,31 +73,29 @@
- - + +
- - + +
-
-
- - +
+
+
-
-
- - +
+
+
@@ -202,6 +200,34 @@ $(document).ready(function(){ M.toast({html: '{{ error_text}}', classes: 'orange'}) {% endif %} }); +$('.chips').chips(); +$('#chips_type').chips({ + placeholder: 'Tipo', + secondaryPlaceholder: '+Altro tipo', + autocompleteOptions: { + data: { + {% for t in types %} + '{{t.name}}': null, + {% endfor %} + }, + limit: Infinity, + minLength: 0 + } +}); +$('#chips_owner').chips({ + placeholder: 'Utente', + secondaryPlaceholder: '+Altro utente', + autocompleteOptions: { + data: { + {% for user in users %} + '{{user.first_name}} {{user.last_name}}': null, + {% endfor %} + }, + limit: Infinity, + minLength: 0 + } +}); + function send(id) { var form = document.getElementById('selection') var action = document.getElementById('action') @@ -221,6 +247,7 @@ $('#select-all').click(function(event) { } }); var options = { + showClearBtn: true, container: document.getElementById('main'), yearRange:100, format:'dd mmmm yyyy', @@ -233,6 +260,7 @@ var options = { today: 'Oggi', clear: 'Cancella', close: 'Chiudi', + cancel: 'Annulla', firstDay: 1, format: 'dddd d mmmm yyyy', formatSubmit: 'yyyy/mm/dd', diff --git a/server/views.py b/server/views.py index f29cb00..9ab4cde 100644 --- a/server/views.py +++ b/server/views.py @@ -352,15 +352,24 @@ def doclist(request): if request.user.is_staff: error = False error_text = "" + + hidden = False + wait = True + selfsign = True + ok = True + + hidden_check = 'checked="checked"' + wait_check = 'checked="checked"' + selfsign_check = 'checked="checked"' + ok_check = 'checked="checked"' + newer = "" + older = "" + if request.method == "POST": selected = [] for i in request.POST.keys(): - if i == "csrfmiddlewaretoken": - continue - if i == "action": - continue - - selected.append(Document.objects.get(id=i)) + if i.isdigit(): + selected.append(Document.objects.get(id=i)) for i in selected: if request.POST["action"] == 'delete': @@ -382,11 +391,30 @@ def doclist(request): else: error = True error_text = "Non puoi dearchiviare un documento non archiviato" + + hidden = "filter_hidden" in request.POST + wait = "filter_wait" in request.POST + selfsign = "filter_selfsign" in request.POST + ok = "filter_ok" in request.POST parent_group = request.user.groups.values_list('name', flat=True)[ 0] group = Group.objects.get(name=parent_group) documents = Document.objects.filter(group=group) + + if not hidden: + documents = documents.filter(~Q(status="archive")) + hidden_check = "" + if not wait: + documents = documents.filter(~Q(status="wait")) + wait_check = "" + if not selfsign: + documents = documents.filter(~Q(status="autosign")) + selfsign_check = "" + if not ok: + documents = documents.filter(~Q(status="ok")) + ok_check = "" + out = [] for i in documents: personal = None @@ -397,8 +425,17 @@ def doclist(request): medical = i.medical_data.__dict__.values() out.append([i, KeyVal.objects.filter(container=i), personal, medical]) + + types = DocumentType.objects.filter(Q(group_private=False) | Q(group=group)) + users = User.objects.filter(groups__name=parent_group) context = { + "types": types, + "users": users, "docs": out, + "hidden_check": hidden_check, + "wait_check": wait_check, + "selfsign_check": selfsign_check, + "ok_check": ok_check, 'error': error, 'error_text': error_text, } -- cgit v1.2.1