diff options
Diffstat (limited to '')
-rw-r--r-- | server/templates/server/doc_list.html | 56 | ||||
-rw-r--r-- | 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 @@ </div> <div class="input-field col s3"> <label> - <input name="filter_public" type="checkbox" class="filled-in" {{public_check}}/> + <input name="filter_wait" type="checkbox" class="filled-in" {{wait_check}}/> <span><i class="material-icons left">timelapse</i>In Attesa</span> </label> </div> @@ -73,31 +73,29 @@ </div> <div class="input-field col s3"> <label> - <input name="filter_personal" type="checkbox" class="filled-in" {{personal_check}}/> + <input name="filter_ok" type="checkbox" class="filled-in" {{ok_check}}/> <span><i class="material-icons left">check</i>Approvati</span> </label> </div> </div> <div class="row"> <div class="input-field col s6"> - <label for="tetanus_date">Più recenti di</label> - <input value="{{tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text" class="datepicker"> + <label for="newer">Più recenti di</label> + <input value="{{newer}}" name="newer" id="newer" type="text" class="datepicker"> </div> <div class="input-field col s6"> - <label for="tetanus_date">Più vecchi di</label> - <input value="{{tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text" class="datepicker"> + <label for="older">Più vecchi di</label> + <input value="{{older}}" name="older" id="older" type="text" class="datepicker"> </div> </div> - <div class ="row"> - <div class="input-field col s12"> - <input value="{{misc}}" name="misc" id="misc" type="text" data-length="250"> - <label for="misc">Tipo di documento</label> + <div class = "row"> + <div class="col s12"> + <div id="chips_type" class="chips chips-placeholder chips-autocomplete"></div> </div> </div> - <div class ="row"> - <div class="input-field col s12"> - <input value="{{misc}}" name="misc" id="misc" type="text" data-length="250"> - <label for="misc">Proprietario del documento</label> + <div class ="row col s12"> + <div class="col s12"> + <div id="chips_owner" class="chips chips-placeholder chips-autocomplete "></div> </div> </div> </div> @@ -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, } |