aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitignore1
-rw-r--r--accounts/templates/accounts/index.html656
-rw-r--r--accounts/views.py48
-rw-r--r--client/migrations/0023_auto_20200622_1708.py24
-rw-r--r--client/migrations/0024_auto_20200622_1930.py23
-rw-r--r--client/models.py2
-rw-r--r--client/templates/client/approve.html2
-rw-r--r--client/templates/client/doc_create.html8
-rw-r--r--client/templates/client/doc_edit.html26
-rw-r--r--client/templates/client/index.html218
-rw-r--r--client/views.py20
-rw-r--r--documents_qtCfYLF0
-rw-r--r--manager/settings.py1
-rw-r--r--server/templates/server/doc_list.html205
-rw-r--r--server/templates/server/download_doc.html265
-rw-r--r--server/views.py34
-rw-r--r--templates/registration/base_client.html51
17 files changed, 1293 insertions, 291 deletions
diff --git a/.gitignore b/.gitignore
index 7668361..7c35346 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
**/__pycache__
**/*.pyc
+documents \ No newline at end of file
diff --git a/accounts/templates/accounts/index.html b/accounts/templates/accounts/index.html
index c1f4624..a6e6edd 100644
--- a/accounts/templates/accounts/index.html
+++ b/accounts/templates/accounts/index.html
@@ -4,7 +4,7 @@
{%block nav%}
<nav class="nav-extended">
- <div class="nav-wrapper red lighten-1">
+ <div class="nav-wrapper teal">
<a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
<a href="#!" class="breadcrumb hide-on-med-and-down">Account</a>
<ul class="right">
@@ -24,7 +24,7 @@
{% endif %}
</ul>
</div>
- <div class="nav-content red lighten-1">
+ <div class="nav-content teal">
<ul class="tabs tabs-transparent">
<li class="tab"><a class="active" href="#personal">Info Personali</a></li>
<li class="tab"><a href="#medic">Info Mediche</a></li>
@@ -55,24 +55,25 @@
<div class="col l8 offset-l2 s12">
<div class="card-panel">
<div class="row">
- <form action="{% url 'personal'%}" method="post" id="form" class="col s12">
+ <form action="{% url 'personal'%}" method="post" id="form" class="col s12" enctype="multipart/form-data">
+ <input type="hidden" name="action" id="action">
+ <input type="hidden" name="delete_vac" id="delete_vac">
+ <input type="hidden" name="delete_health" id="delete_health">
{% csrf_token %}
<div class="row">
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input name="first_name" value="{{first_name}}" id="first_name" type="text" >
<label for="first_name">Nome</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input name="last_name" value="{{last_name}}" id="last_name" type="text" >
<label for="last_name">Cognome</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input name="birth_date" value="{{birth_date}}" id="birth_date" type="text" class="datepicker">
<label for="birth_date">Data di nascita</label>
</div>
- </div>
- <div class="row">
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<select name="branca">
<option value="" disabled {{branca_default}}>Scegli</option>
<option value="colonia" {{branca_castorini}}>Castorini</option>
@@ -83,57 +84,49 @@
</select>
<label>Branca</label>
</div>
- <div class="input-field col s8">
+ <div class="input-field col l8 s12">
<input value="{{parent_name}}" name="parent_name" id="parent_name" type="text" >
<label for="parent_name">Nome dei genitori</label>
</div>
- </div>
- <div class="row">
- <div class="input-field col s12">
+ <div class="input-field col l12 s12">
<input value="{{via}}" name="via" id="via" type="text" >
<label for="via">Via e numero</label>
</div>
- </div>
- <div class="row">
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input value="{{cap}}" name="cap" id="cap" type="text" >
<label for="cap">CAP</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input value="{{country}}" name="country" id="country" type="text" >
<label for="country">Paese</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input value="{{nationality}}" name="nationality" id="nationality" type="text" >
<label for="nationality">Nazionalit&agrave;</label>
</div>
- </div>
- <div class="row">
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input value="{{phone}}" name="phone" id="phone" type="text" >
<label for="phone">Cellulare</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input value="{{home_phone}}" name="home_phone" id="home_phone" type="text" >
<label for="home_phone">Telefono di casa</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input value="{{email}}" name="email" id="email" type="text" >
<label for="email">Email</label>
</div>
- </div>
- <div class="row">
- <div class="input-field col s8">
+ <div class="input-field col l8 s12">
<input value="{{school}}" name="school" id="school" type="text" >
<label for="school">Scuola frequentata</label>
</div>
- <div class="input-field col s4">
+ <div class="input-field col l4 s12">
<input value="{{year}}" name="year" id="year" type="text" >
<label for="year">Classe</label>
</div>
</div>
<div class="fixed-action-btn">
- <a class="btn-floating btn-large red lighten-1" onclick="document.getElementById('form').submit()">
+ <a class="btn-floating btn-large teal" onclick="document.getElementById('form').submit()">
<i class="large material-icons">save</i>
</a>
</div>
@@ -145,210 +138,437 @@
<div class="col l8 offset-l2 s12">
<div class="card-panel">
<div class="row">
- {% csrf_token %}
- <div class="row">
- <div class="col s12">
- <h6>Persona di contatto in caso di necessit&agrave;</h6>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s6">
- <input name="emer_name" value="{{emer_name}}" id="emer_name" type="text" >
- <label for="emer_name">Nome e cognome</label>
- </div>
- <div class="input-field col s3">
- <input name="emer_relative" value="{{emer_relative}}" id="emer_relative" type="text" >
- <label for="emer_releative">Parentela</label>
- </div>
- <div class="input-field col s3">
- <input name="cell_phone" value="{{cell_phone}}" id="cellphone" type="text" >
- <label for="cell_phone">Cellulare</label>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s9">
- <input value="{{address}}" name="address" id="address" type="text" >
- <label for="address">Indirizzo completo</label>
- </div>
- <div class="input-field col s3">
- <input value="{{emer_phone}}" name="emer_phone" id="emer_phone" type="text" >
- <label for="emer_phone">Telefono di casa</label>
- </div>
- </div>
- <div class="row">
- <div class="col s12">
- <h6>Assicurazione</h6>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s4">
- <input value="{{health_care}}" name="health_care" id="health_care" type="text" >
- <label for="health_care">Cassa Malati</label>
- </div>
- <div class="input-field col s4">
- <input value="{{injuries}}" name="injuries" id="injuries" type="text" >
- <label for="injuries">Infortuni</label>
- </div>
- <div class="input-field col s4">
- <input value="{{rc}}" name="rc" id="rc" type="text" >
- <label for="rc">Responsabilit&agrave; civile</label>
- </div>
- </div>
- <div class="row">
- <div class="switch col s12">
- &Egrave; sostenitore REGA&nbsp;&nbsp;
- <label>
- No
- <input name="rega" type="checkbox" {{rega_check}}>
- <span class="lever"></span>
- Si
- </label>
- </div>
- </div>
- <div class="row">
- <div class="col s12">
- <h6>Medico di famiglia</h6>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s6">
- <input value="{{medic_name}}" name="medic_name" id="medic_name" type="text" >
- <label for="medic_name">Nome e cognome</label>
- </div>
- <div class="input-field col s6">
- <input value="{{medic_phone}}" name="medic_phone" id="medic_phone" type="text" >
- <label for="medic_phone">Telefono studio</label>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s12">
- <input value="{{medic_address}}" name="medic_address" id="medic_address" type="text" >
- <label for="medic_address">Indirizzo completo</label>
- </div>
- </div>
- <div class="row">
- <div class="col s12">
- <h6>Scheda medica personale</h6>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s12">
- <input value="{{sickness}}" name="sickness" id="sickness" type="text" data-length="250">
- <label for="sickness">Principali malattie avute</label>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s8">
- <input value="{{vaccine}}" name="vaccine" id="vaccine" type="text" data-length="250">
- <label for="vaccine">Vacinazioni fatte</label>
- </div>
- <div class="input-field col s4">
- <label for="tetanus_date">Ultima vacinazione contro il tetano</label>
- <input value="{{tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text" class="datepicker">
- </div>
- </div>
- <div class="row">
- <div class="input-field col s12">
- <input value="{{allergy}}" name="allergy" id="allergy" type="text" data-length="250">
- <label for="allergy">Allergie particolari/Intolleraze alimentari</label>
- </div>
- </div>
- <div class="row">
- <div class="switch col s12">
- Deve assumere regolarmente medicamenti&nbsp;&nbsp;
- <label>
- No
- <input name="drugs_bool" type="checkbox" {{drugs_check}}>
- <span class="lever"></span>
- Si
- </label>
+ <div class="col s12">
+ <h6>Persona di contatto in caso di necessit&agrave;</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l6 s12">
+ <input name="emer_name" value="{{emer_name}}" id="emer_name" type="text" >
+ <label for="emer_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input name="emer_relative" value="{{emer_relative}}" id="emer_relative" type="text" >
+ <label for="emer_releative">Parentela</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input name="cell_phone" value="{{cell_phone}}" id="cellphone" type="text" >
+ <label for="cell_phone">Cellulare</label>
+ </div>
+ <div class="input-field col l9 s12">
+ <input value="{{address}}" name="address" id="address" type="text" >
+ <label for="address">Indirizzo completo</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input value="{{emer_phone}}" name="emer_phone" id="emer_phone" type="text" >
+ <label for="emer_phone">Telefono di casa</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Assicurazione</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input value="{{health_care}}" name="health_care" id="health_care" type="text" >
+ <label for="health_care">Cassa Malati</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{injuries}}" name="injuries" id="injuries" type="text" >
+ <label for="injuries">Infortuni</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{rc}}" name="rc" id="rc" type="text" >
+ <label for="rc">Responsabilit&agrave; civile</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="switch col s12">
+ &Egrave; sostenitore REGA&nbsp;&nbsp;
+ <label>
+ No
+ <input name="rega" type="checkbox" {{rega_check}}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Medico di famiglia</h6>
+ </div>
+ <div class="input-field col l6 s12">
+ <input value="{{medic_name}}" name="medic_name" id="medic_name" type="text" >
+ <label for="medic_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l6 s12">
+ <input value="{{medic_phone}}" name="medic_phone" id="medic_phone" type="text" >
+ <label for="medic_phone">Telefono studio</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input value="{{medic_address}}" name="medic_address" id="medic_address" type="text" >
+ <label for="medic_address">Indirizzo completo</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Scheda medica personale</h6>
+ </div>
+ <div class="input-field col s12">
+ <input value="{{sickness}}" name="sickness" id="sickness" type="text" data-length="250">
+ <label for="sickness">Principali malattie avute</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input value="{{vaccine}}" name="vaccine" id="vaccine" type="text" data-length="250">
+ <label for="vaccine">Vacinazioni fatte</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <label for="tetanus_date">Ultima vacinazione contro il tetano</label>
+ <input value="{{tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text" class="datepicker">
+ </div>
+ <div class="input-field col s12">
+ <input value="{{allergy}}" name="allergy" id="allergy" type="text" data-length="250">
+ <label for="allergy">Allergie particolari/Intolleraze alimentari</label>
+ </div>
+ <div class="switch col s12">
+ Deve assumere regolarmente medicamenti&nbsp;&nbsp;
+ <label>
+ No
+ <input name="drugs_bool" type="checkbox" {{drugs_check}}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="col s12">
+ <div class="card teal">
+ <div class="card-content">
+ <p style="color:white"><b>In caso dovesse assumere farmaci, avvisare comunque i capi</b></p>
</div>
</div>
- <div class="row">
- <div class="col s12">
- <div class="card red lighten-1">
- <div class="card-content">
- <p style="color:white"><b>In caso dovesse assumere farmaci, avvisare comunque i capi</b></p>
+ </div>
+ <div class="input-field col s12">
+ <input value="{{drugs}}" name="drugs" id="drugs" type="text" data-length="250">
+ <label for="drugs">Se s&igrave; quali, in che dosi e prescrizioni</label>
+ </div>
+ <div class="switch col s12">
+ Informazioni particolari sullo stato di salute: (postumi di operazioni, incidenti, malattie, disturbi fisici)&nbsp;&nbsp;
+ <label>
+ No
+ <input name="misc_bool" type="checkbox" {{misc_check}}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input value="{{misc}}" name="misc" id="misc" type="text" data-length="250">
+ <label for="misc">Se s&igrave; quali</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Allegati</h6>
+ </div>
+ <div class="col s12">
+ <div class="card">
+ <div class="card-content">
+ Certificato di vacinazione
+ <div class="file-field input-field">
+ <div class="btn teal">
+ <span><i class="material-icons left">file_upload</i>File</span>
+ <input type="file" name="vac_certificate">
+ </div>
+ <div class="file-path-wrapper">
+ <input id="vac_file" value="{{vac_certificate}}" class="file-path" type="text" placeholder="Certificato di vacinazione">
</div>
</div>
- </div>
- <div class="input-field col s12">
- <input value="{{drugs}}" name="drugs" id="drugs" type="text" data-length="250">
- <label for="drugs">Se s&igrave; quali, in che dosi e prescrizioni</label>
- </div>
- </div>
- <div class="row">
- <div class="switch col s12">
- Informazioni particolari sullo stato di salute: (postumi di operazioni, incidenti, malattie, disturbi fisici)&nbsp;&nbsp;
- <label>
- No
- <input name="misc_bool" type="checkbox" {{misc_check}}>
- <span class="lever"></span>
- Si
- </label>
- </div>
- <div class="input-field col s12">
- <input value="{{misc}}" name="misc" id="misc" type="text" data-length="250">
- <label for="misc">Se s&igrave; quali</label>
- </div>
- </div>
- <div class="row">
- <div class="col s12">
- <h6>Allegati</h6>
+ {% if vac_certificate != ''%}
+ <a class="btn teal" onclick="send('download_vac')"><i class="material-icons left">file_download</i>Download</a>
+ <a class="btn teal" onclick="delete_vac()"><i class="material-icons left">delete</i><span>Elimina</span></a>
+ {% endif %}
</div>
</div>
- <div class="row">
- <div class="col s6">
- Certificato delle vacinazioni
- </div>
- <div class="col s6">
- Tessera della cassa malati
+ </div>
+ <div class="col s12">
+ <div class="card">
+ <div class="card-content">
+ Tessera cassa malati
+ <div class="file-field input-field">
+ <div class="btn teal">
+ <span><i class="material-icons left">file_upload</i>File</span>
+ <input type="file" name="health_care_certificate">
+ </div>
+ <div class="file-path-wrapper">
+ <input id="health_care_file" value="{{health_care_certificate}}" class="file-path" type="text" placeholder="Tessera cassa malati">
+ </div>
+ </div>
+ {% if health_care_certificate != ''%}
+ <a class="btn teal" onclick="send('download_health')"><i class="material-icons left">file_download</i>Download</a>
+ <a class="btn teal" onclick="delete_health()"><i class="material-icons left">delete</i><span>Elimina</span></a>
+ {% endif %}
</div>
</div>
- <div class="fixed-action-btn">
- <a class="btn-floating btn-large red lighten-1" onclick="document.getElementById('form').submit()">
- <i class="large material-icons">save</i>
- </a>
- </div>
- </form>
+ </div>
+ </div>
+ <div class="fixed-action-btn">
+ <a class="btn-floating btn-large teal" onclick="send('save')">
+ <i class="large material-icons">save</i>
+ </a>
</div>
+ </form>
</div>
</div>
</div>
{% endblock %}
{% block script %}
- var elem = $('.tabs')
- var options = {
- yearRange:100,
- format:'dd mmmm yyyy',
- i18n: {
- months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ],
- monthsShort: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic' ],
- weekdays: [ 'domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato' ],
- weekdaysShort: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ],
- weekdaysAbbrev: [ 'D', 'L', 'M', 'M', 'G', 'V', 'S' ],
- today: 'Oggi',
- clear: 'Cancella',
- close: 'Chiudi',
- firstDay: 1,
- format: 'dddd d mmmm yyyy',
- formatSubmit: 'yyyy/mm/dd',
- labelMonthNext: 'Mese successivo',
- labelMonthPrev: 'Mese precedente',
- labelMonthSelect: 'Seleziona un mese',
- labelYearSelect: 'Seleziona un anno'
- }}
- var instance = M.Tabs.init(elem, options);
- document.addEventListener('DOMContentLoaded', function() {
- var elems = document.querySelectorAll('.datepicker');
- var instances = M.Datepicker.init(elems, options);
- });
- document.addEventListener('DOMContentLoaded', function() {
- var elems = document.querySelectorAll('select');
- var instances = M.FormSelect.init(elems, options);
- });
- $(document).ready(function() {
- $('input#sickness, input#vaccine, input#allergy, input#drugs, input#misc').characterCounter();
+function send(id) {
+ var form = document.getElementById('form');
+ var action = document.getElementById('action');
+ action.setAttribute('value', id);
+ form.submit();
+}
+
+function delete_vac() {
+ var action = document.getElementById('delete_vac');
+ var text = document.getElementById('vac_file');
+ action.setAttribute('value', 'vac');
+ text.setAttribute('value', '');
+}
+
+function delete_health() {
+ var action = document.getElementById('delete_health');
+ var text = document.getElementById('health_care_file');
+ action.setAttribute('value', 'health');
+ text.setAttribute('value', '');
+}
+
+var elem = $('.tabs')
+var options = {
+ yearRange:100,
+ format:'dd mmmm yyyy',
+ i18n: {
+ months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ],
+ monthsShort: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic' ],
+ weekdays: [ 'domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato' ],
+ weekdaysShort: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ],
+ weekdaysAbbrev: [ 'D', 'L', 'M', 'M', 'G', 'V', 'S' ],
+ today: 'Oggi',
+ clear: 'Cancella',
+ close: 'Chiudi',
+ firstDay: 1,
+ format: 'dddd d mmmm yyyy',
+ formatSubmit: 'yyyy/mm/dd',
+ labelMonthNext: 'Mese successivo',
+ labelMonthPrev: 'Mese precedente',
+ labelMonthSelect: 'Seleziona un mese',
+ labelYearSelect: 'Seleziona un anno'
+ }}
+var instance = M.Tabs.init(elem, options);
+document.addEventListener('DOMContentLoaded', function() {
+var elems = document.querySelectorAll('.datepicker');
+var instances = M.Datepicker.init(elems, options);
+});
+document.addEventListener('DOMContentLoaded', function() {
+var elems = document.querySelectorAll('select');
+var instances = M.FormSelect.init(elems, options);
+});
+$(document).ready(function() {
+$('input#sickness, input#vaccine, input#allergy, input#drugs, input#misc').characterCounter();
+});
+
+/*!
+ * jQuery Plugin: Are-You-Sure (Dirty Form Detection)
+ * https://github.com/codedance/jquery.AreYouSure/
+ *
+ * Copyright (c) 2012-2014, Chris Dance and PaperCut Software http://www.papercut.com/
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Author: chris.dance@papercut.com
+ * Version: 1.9.0
+ * Date: 13th August 2014
+ */
+(function($) {
+
+ $.fn.areYouSure = function(options) {
+
+ var settings = $.extend(
+ {
+ 'message' : 'You have unsaved changes!',
+ 'dirtyClass' : 'dirty',
+ 'change' : null,
+ 'silent' : false,
+ 'addRemoveFieldsMarksDirty' : false,
+ 'fieldEvents' : 'change keyup propertychange input',
+ 'fieldSelector': ":input:not(input[type=submit]):not(input[type=button])"
+ }, options);
+
+ var getValue = function($field) {
+ if ($field.hasClass('ays-ignore')
+ || $field.hasClass('aysIgnore')
+ || $field.attr('data-ays-ignore')
+ || $field.attr('name') === undefined) {
+ return null;
+ }
+
+ if ($field.is(':disabled')) {
+ return 'ays-disabled';
+ }
+
+ var val;
+ var type = $field.attr('type');
+ if ($field.is('select')) {
+ type = 'select';
+ }
+
+ switch (type) {
+ case 'checkbox':
+ case 'radio':
+ val = $field.is(':checked');
+ break;
+ case 'select':
+ val = '';
+ $field.find('option').each(function(o) {
+ var $option = $(this);
+ if ($option.is(':selected')) {
+ val += $option.val();
+ }
+ });
+ break;
+ default:
+ val = $field.val();
+ }
+
+ return val;
+ };
+
+ var storeOrigValue = function($field) {
+ $field.data('ays-orig', getValue($field));
+ };
+
+ var checkForm = function(evt) {
+
+ var isFieldDirty = function($field) {
+ var origValue = $field.data('ays-orig');
+ if (undefined === origValue) {
+ return false;
+ }
+ return (getValue($field) != origValue);
+ };
+
+ var $form = ($(this).is('form'))
+ ? $(this)
+ : $(this).parents('form');
+
+ // Test on the target first as it's the most likely to be dirty
+ if (isFieldDirty($(evt.target))) {
+ setDirtyStatus($form, true);
+ return;
+ }
+
+ $fields = $form.find(settings.fieldSelector);
+
+ if (settings.addRemoveFieldsMarksDirty) {
+ // Check if field count has changed
+ var origCount = $form.data("ays-orig-field-count");
+ if (origCount != $fields.length) {
+ setDirtyStatus($form, true);
+ return;
+ }
+ }
+
+ // Brute force - check each field
+ var isDirty = false;
+ $fields.each(function() {
+ var $field = $(this);
+ if (isFieldDirty($field)) {
+ isDirty = true;
+ return false; // break
+ }
+ });
+
+ setDirtyStatus($form, isDirty);
+ };
+
+ var initForm = function($form) {
+ var fields = $form.find(settings.fieldSelector);
+ $(fields).each(function() { storeOrigValue($(this)); });
+ $(fields).unbind(settings.fieldEvents, checkForm);
+ $(fields).bind(settings.fieldEvents, checkForm);
+ $form.data("ays-orig-field-count", $(fields).length);
+ setDirtyStatus($form, false);
+ };
+
+ var setDirtyStatus = function($form, isDirty) {
+ var changed = isDirty != $form.hasClass(settings.dirtyClass);
+ $form.toggleClass(settings.dirtyClass, isDirty);
+
+ // Fire change event if required
+ if (changed) {
+ if (settings.change) settings.change.call($form, $form);
+
+ if (isDirty) $form.trigger('dirty.areYouSure', [$form]);
+ if (!isDirty) $form.trigger('clean.areYouSure', [$form]);
+ $form.trigger('change.areYouSure', [$form]);
+ }
+ };
+
+ var rescan = function() {
+ var $form = $(this);
+ var fields = $form.find(settings.fieldSelector);
+ $(fields).each(function() {
+ var $field = $(this);
+ if (!$field.data('ays-orig')) {
+ storeOrigValue($field);
+ $field.bind(settings.fieldEvents, checkForm);
+ }
+ });
+ // Check for changes while we're here
+ $form.trigger('checkform.areYouSure');
+ };
+
+ var reinitialize = function() {
+ initForm($(this));
+ }
+
+ if (!settings.silent && !window.aysUnloadSet) {
+ window.aysUnloadSet = true;
+ $(window).bind('beforeunload', function() {
+ $dirtyForms = $("form").filter('.' + settings.dirtyClass);
+ if ($dirtyForms.length == 0) {
+ return;
+ }
+ // Prevent multiple prompts - seen on Chrome and IE
+ if (navigator.userAgent.toLowerCase().match(/msie|chrome/)) {
+ if (window.aysHasPrompted) {
+ return;
+ }
+ window.aysHasPrompted = true;
+ window.setTimeout(function() {window.aysHasPrompted = false;}, 900);
+ }
+ return settings.message;
+ });
+ }
+
+ return this.each(function(elem) {
+ if (!$(this).is('form')) {
+ return;
+ }
+ var $form = $(this);
+
+ $form.submit(function() {
+ $form.removeClass(settings.dirtyClass);
+ });
+ $form.bind('reset', function() { setDirtyStatus($form, false); });
+ // Add a custom events
+ $form.bind('rescan.areYouSure', rescan);
+ $form.bind('reinitialize.areYouSure', reinitialize);
+ $form.bind('checkform.areYouSure', checkForm);
+ initForm($form);
});
+ };
+})(jQuery);
+$('form').areYouSure();
+
{% endblock %} \ No newline at end of file
diff --git a/accounts/views.py b/accounts/views.py
index 804a841..9c2efeb 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -3,10 +3,12 @@ from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
from django.views import generic
from django.contrib.auth.models import Group
+from django.core.files.storage import FileSystemStorage
+from django.http import FileResponse
from client.models import UserCode
-import dateparser
+import dateparser, os
class SignUp(generic.CreateView):
@@ -29,6 +31,18 @@ def personal(request):
branca_rover = ""
if request.method == "POST":
+ if request.POST['action'] == "download_vac":
+ if medic.vac_certificate != None:
+ filename = os.path.basename(medic.vac_certificate.name)
+ filename = filename[filename.find("_")+1:]
+ return FileResponse(medic.vac_certificate.file, as_attachment=True, filename=filename)
+
+ if request.POST['action'] == "download_health":
+ if medic.health_care_certificate != None:
+ filename = os.path.basename(medic.health_care_certificate.name)
+ filename = filename[filename.find("_")+1:]
+ return FileResponse(medic.health_care_certificate.file, as_attachment=True, filename=filename)
+
request.user.first_name = request.POST["first_name"]
request.user.last_name = request.POST["last_name"]
request.user.email = request.POST["email"]
@@ -71,6 +85,24 @@ def personal(request):
request.user.groups.clear()
request.user.groups.add(
Group.objects.get(name=request.POST["branca"]))
+
+ if "vac_certificate" in request.FILES:
+ myfile = request.FILES['vac_certificate']
+ medic.vac_certificate.save(request.user.username+"_"+myfile.name, myfile)
+ medic.save()
+
+ if "health_care_certificate" in request.FILES:
+ myfile = request.FILES['health_care_certificate']
+ medic.health_care_certificate.save(request.user.username+"_"+myfile.name, myfile)
+ medic.save()
+
+ if request.POST["delete_vac"] == 'vac':
+ medic.vac_certificate.delete()
+ medic.save()
+
+ if request.POST["delete_health"] == 'health':
+ medic.health_care_certificate.delete()
+ medic.save()
if len(request.user.groups.values_list('name', flat=True)) == 0:
branca_default = "selected"
@@ -100,6 +132,18 @@ def personal(request):
if medic.misc_bool:
misc = "checked='checked'"
+ if (medic.vac_certificate != None):
+ vac_name = os.path.basename(medic.vac_certificate.name)
+ vac_name = vac_name[vac_name.find("_")+1:]
+ else:
+ vac_name = ''
+
+ if (medic.health_care_certificate != None):
+ card_name = os.path.basename(medic.health_care_certificate.name)
+ card_name = card_name[card_name.find("_")+1:]
+ else:
+ card_name = ''
+
context = {
'first_name': request.user.first_name,
'last_name': request.user.last_name,
@@ -140,6 +184,8 @@ def personal(request):
'drugs': medic.drugs,
'misc_check': misc,
'misc': medic.misc,
+ 'health_care_certificate': card_name,
+ 'vac_certificate': vac_name,
}
return render(request, 'accounts/index.html', context)
diff --git a/client/migrations/0023_auto_20200622_1708.py b/client/migrations/0023_auto_20200622_1708.py
new file mode 100644
index 0000000..458ec6d
--- /dev/null
+++ b/client/migrations/0023_auto_20200622_1708.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.0.7 on 2020-06-22 15:08
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('client', '0022_auto_20200620_2316'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='medicaldata',
+ name='health_care_certificate',
+ field=models.FileField(default=None, upload_to='documents/'),
+ ),
+ migrations.AddField(
+ model_name='medicaldata',
+ name='vac_certificate',
+ field=models.FileField(default=None, upload_to='documents/'),
+ preserve_default=False,
+ ),
+ ]
diff --git a/client/migrations/0024_auto_20200622_1930.py b/client/migrations/0024_auto_20200622_1930.py
new file mode 100644
index 0000000..f721298
--- /dev/null
+++ b/client/migrations/0024_auto_20200622_1930.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.0.7 on 2020-06-22 17:30
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('client', '0023_auto_20200622_1708'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='medicaldata',
+ name='health_care_certificate',
+ field=models.FileField(default=None, null=True, upload_to='documents/'),
+ ),
+ migrations.AlterField(
+ model_name='medicaldata',
+ name='vac_certificate',
+ field=models.FileField(null=True, upload_to='documents/'),
+ ),
+ ]
diff --git a/client/models.py b/client/models.py
index 78b8df4..105165b 100644
--- a/client/models.py
+++ b/client/models.py
@@ -51,6 +51,8 @@ class MedicalData(models.Model):
drugs = models.CharField(default="", max_length=250)
misc_bool = models.BooleanField(default=False)
misc = models.CharField(default="", max_length=250)
+ vac_certificate = models.FileField(upload_to='documents/', null=True)
+ health_care_certificate = models.FileField(default=None, upload_to='documents/', null=True)
class Document(models.Model):
diff --git a/client/templates/client/approve.html b/client/templates/client/approve.html
index e00aedc..f440fbe 100644
--- a/client/templates/client/approve.html
+++ b/client/templates/client/approve.html
@@ -1,4 +1,4 @@
-{% extends 'registration/base.html' %}
+{% extends 'registration/base_client.html' %}
{% block title %}Approva{% endblock %}
diff --git a/client/templates/client/doc_create.html b/client/templates/client/doc_create.html
index a095c04..710ba29 100644
--- a/client/templates/client/doc_create.html
+++ b/client/templates/client/doc_create.html
@@ -1,4 +1,4 @@
-{% extends 'registration/base.html' %}
+{% extends 'registration/base_client.html' %}
{% block title %}Crea Documento{% endblock %}
@@ -46,7 +46,7 @@
{% if personal_data %}
<div class="row">
<div class="col s12">
- <div class="card red lighten-1">
+ <div class="card teal">
<div class="card-content">
<p style="color:white"><b>
Il documento conterr&agrave; le informazioni personali, prego verificare che siano corrette e aggiornate
@@ -59,7 +59,7 @@
{% if medical_data %}
<div class="row">
<div class="col s12">
- <div class="card red lighten-1">
+ <div class="card teal">
<div class="card-content">
<p style="color:white"><b>
Il documento conterr&agrave; le informazioni mediche, prego verificare che siano corrette e aggiornate
@@ -72,7 +72,7 @@
{% if custom_message %}
<div class="row">
<div class="col s12">
- <div class="card red lighten-1">
+ <div class="card teal">
<div class="card-content">
<p style="color:white"><b>
{{custom_message_text}}
diff --git a/client/templates/client/doc_edit.html b/client/templates/client/doc_edit.html
index 8cd5a98..0048fd5 100644
--- a/client/templates/client/doc_edit.html
+++ b/client/templates/client/doc_edit.html
@@ -1,4 +1,4 @@
-{% extends 'registration/base.html' %}
+{% extends 'registration/base_client.html' %}
{% block title %}Modifica documento{% endblock %}
@@ -26,21 +26,39 @@
{% if personal_data %}
<div class="row">
<div class="col s12">
- <a style="pointer-events: none; cursor: default;" class="btn red lighten-1"> Il documento conterr&agrave; le informazioni personali, prego verificare che siano corrette e aggiornate</a>
+ <div class="card teal">
+ <div class="card-content">
+ <p style="color:white"><b>
+ Il documento conterr&agrave; le informazioni personali, prego verificare che siano corrette e aggiornate
+ </b></p>
+ </div>
+ </div>
</div>
</div>
{% endif %}
{% if medical_data %}
<div class="row">
<div class="col s12">
- <a style="pointer-events: none; cursor: default;" class="btn red lighten-1"> Il documento conterr&agrave; le informazioni mediche, prego verificare che siano corrette e aggiornate</a>
+ <div class="card teal">
+ <div class="card-content">
+ <p style="color:white"><b>
+ Il documento conterr&agrave; le informazioni mediche, prego verificare che siano corrette e aggiornate
+ </b></p>
+ </div>
+ </div>
</div>
</div>
{% endif %}
{% if custom_message %}
<div class="row">
<div class="col s12">
- <a style="pointer-events: none; cursor: default;" class="btn red lighten-1">{{custom_message_text}}</a>
+ <div class="card teal">
+ <div class="card-content">
+ <p style="color:white"><b>
+ {{custom_message_text}}
+ </b></p>
+ </div>
+ </div>
</div>
</div>
{% endif %}
diff --git a/client/templates/client/index.html b/client/templates/client/index.html
index 733f62f..ff12e74 100644
--- a/client/templates/client/index.html
+++ b/client/templates/client/index.html
@@ -1,4 +1,4 @@
-{% extends 'registration/base.html' %}
+{% extends 'registration/base_client.html' %}
{% block title %}Home{% endblock %}
@@ -7,10 +7,10 @@
{% endblock%}
{% block content %}
-<div class="tap-target" data-target="add">
+<div class="tap-target teal" data-target="add">
<div class="tap-target-content">
- <h5>Aggiungi un documento</h5>
- <p>Usa questo bottone per creare un nuovo documento</p>
+ <h5 style="color:white">Aggiungi un documento</h5>
+ <p style="color:white">Usa questo bottone per creare un nuovo documento</p>
</div>
</div>
@@ -38,15 +38,15 @@
</div>
<div class="collapsible-body"><span>
{% if doc.0.status == "wait" %}
- <a class="waves-effect waves-light btn red lighten-1" onclick="send('f{{doc.0.id}}')"><i class="material-icons left">file_download</i> Scarica documento per approvazione</a>
- <a class="waves-effect waves-light btn red lighten-1" onclick="send('d{{doc.0.id}}')"><i class="material-icons left">delete</i> Elimina documento</a>
- <a class="waves-effect waves-light btn red lighten-1" onclick="send('e{{doc.0.id}}')"><i class="material-icons left">edit</i> Modifica documento</a>
+ <a class="waves-effect waves-light btn teal" onclick="send('f{{doc.0.id}}')"><i class="material-icons left">file_download</i> Scarica documento per approvazione</a>
+ <a class="waves-effect waves-light btn teal" onclick="send('d{{doc.0.id}}')"><i class="material-icons left">delete</i> Elimina documento</a>
+ <a class="waves-effect waves-light btn teal" onclick="send('e{{doc.0.id}}')"><i class="material-icons left">edit</i> Modifica documento</a>
<br>
<br>
{% elif doc.0.status == "autosign" %}
- <a class="waves-effect waves-light btn red lighten-1" onclick="send('a{{doc.0.id}}')"><i class="material-icons left">check</i>Approva documento</a>
- <a class="waves-effect waves-light btn red lighten-1" onclick="send('d{{doc.0.id}}')"><i class="material-icons left">delete</i> Elimina documento</a>
- <a class="waves-effect waves-light btn red lighten-1" onclick="send('e{{doc.0.id}}')"><i class="material-icons left">edit</i> Modifica documento</a>
+ <a class="waves-effect waves-light btn teal" onclick="send('a{{doc.0.id}}')"><i class="material-icons left">check</i>Approva documento</a>
+ <a class="waves-effect waves-light btn teal" onclick="send('d{{doc.0.id}}')"><i class="material-icons left">delete</i> Elimina documento</a>
+ <a class="waves-effect waves-light btn teal" onclick="send('e{{doc.0.id}}')"><i class="material-icons left">edit</i> Modifica documento</a>
<br>
<br>
{% endif %}
@@ -57,15 +57,64 @@
<i class="material-icons">person</i>Dati personali
</div>
<div class="collapsible-body"><span>
- <table class="striped">
- <tbody>
- {% for field in doc.2 %}
- <tr>
- <td>{{field}}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.0.user.first_name}}" id="first_name" type="text" >
+ <label for="first_name">Nome</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.0.user.last_name}}" id="last_name" type="text" >
+ <label for="last_name">Cognome</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.born_date}}" id="birth_date" type="text">
+ <label for="birth_date">Data di nascita</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.4}}" id="branca" type="text">
+ <label for="branca">Branca</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{doc.2.parent_name}}" id="parent_name" type="text" >
+ <label for="parent_name">Nome dei genitori</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input value="{{doc.2.via}}" disabled id="via" type="text" >
+ <label for="via">Via e numero</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.cap}}" name="cap" id="cap" type="text" >
+ <label for="cap">CAP</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.country}}" name="country" id="country" type="text" >
+ <label for="country">Paese</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.nationality}}" name="nationality" id="nationality" type="text" >
+ <label for="nationality">Nazionalit&agrave;</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.phone}}" name="phone" id="phone" type="text" >
+ <label for="phone">Cellulare</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.home_phone}}" name="home_phone" id="home_phone" type="text" >
+ <label for="home_phone">Telefono di casa</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.email}}" name="email" id="email" type="text" >
+ <label for="email">Email</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{doc.2.school}}" name="school" id="school" type="text" >
+ <label for="school">Scuola frequentata</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.year}}" name="year" id="year" type="text" >
+ <label for="year">Classe</label>
+ </div>
+ </div>
</span></div>
</li>
{% endif %}
@@ -75,15 +124,126 @@
<i class="material-icons">healing</i>Dati medici
</div>
<div class="collapsible-body"><span>
- <table class="striped">
- <tbody>
- {% for field in doc.3 %}
- <tr>
- <td>{{field}}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
+ <div class="row">
+ <div class="col s12">
+ <h6>Persona di contatto in caso di necessit&agrave;</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l6 s12">
+ <input disabled name="emer_name" value="{{doc.3.emer_name}}" id="emer_name" type="text" >
+ <label for="emer_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled name="emer_relative" value="{{doc.3.emer_relative}}" id="emer_relative" type="text" >
+ <label for="emer_releative">Parentela</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled name="cell_phone" value="{{doc.3.cell_phone}}" id="cellphone" type="text" >
+ <label for="cell_phone">Cellulare</label>
+ </div>
+ <div class="input-field col l9 s12">
+ <input disabled value="{{doc.3.address}}" name="address" id="address" type="text" >
+ <label for="address">Indirizzo completo</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled value="{{doc.3.emer_phone}}" name="emer_phone" id="emer_phone" type="text" >
+ <label for="emer_phone">Telefono di casa</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Assicurazione</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.3.health_care}}" name="health_care" id="health_care" type="text" >
+ <label for="health_care">Cassa Malati</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.3.injuries}}" name="injuries" id="injuries" type="text" >
+ <label for="injuries">Infortuni</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.3.rc}}" name="rc" id="rc" type="text" >
+ <label for="rc">Responsabilit&agrave; civile</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="switch col s12">
+ &Egrave; sostenitore REGA&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="rega" type="checkbox" {% if doc.3.rega %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Medico di famiglia</h6>
+ </div>
+ <div class="input-field col l6 s12">
+ <input disabled value="{{doc.3.medic_name}}" name="medic_name" id="medic_name" type="text" >
+ <label for="medic_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l6 s12">
+ <input disabled value="{{doc.3.medic_phone}}" name="medic_phone" id="medic_phone" type="text" >
+ <label for="medic_phone">Telefono studio</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input disabled value="{{doc.3.medic_address}}" name="medic_address" id="medic_address" type="text" >
+ <label for="medic_address">Indirizzo completo</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Scheda medica personale</h6>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.3.sickness}}" name="sickness" id="sickness" type="text">
+ <label for="sickness">Principali malattie avute</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{doc.3.vaccine}}" name="vaccine" id="vaccine" type="text">
+ <label for="vaccine">Vacinazioni fatte</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <label for="tetanus_date">Ultima vacinazione contro il tetano</label>
+ <input disabled value="{{doc.3.tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text">
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.3.allergy}}" name="allergy" id="allergy" type="text">
+ <label for="allergy">Allergie particolari/Intolleraze alimentari</label>
+ </div>
+ <div class="switch col s12">
+ Deve assumere regolarmente medicamenti&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="drugs_bool" type="checkbox" {% if doc.3.drugs_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.3.drugs}}" name="drugs" id="drugs" type="text">
+ <label for="drugs">Se s&igrave; quali, in che dosi e prescrizioni</label>
+ </div>
+ <div class="switch col s12">
+ Informazioni particolari sullo stato di salute: (postumi di operazioni, incidenti, malattie, disturbi fisici)&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="misc_bool" type="checkbox" {% if doc.3.misc_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.3.misc}}" name="misc" id="misc" type="text">
+ <label for="misc">Se s&igrave; quali</label>
+ </div>
</span></div>
</li>
{% endif %}
@@ -113,7 +273,7 @@
</ul>
{% endif %}
<div class="fixed-action-btn">
- <a id="add" class="btn-floating btn-large red lighten-1" href="{% url 'create'%}">
+ <a id="add" class="btn-floating btn-large teal" href="{% url 'create'%}">
<i class="large material-icons">add</i>
</a>
</div>
diff --git a/client/views.py b/client/views.py
index b16e64a..b43a3c9 100644
--- a/client/views.py
+++ b/client/views.py
@@ -6,9 +6,9 @@ from django.http import HttpResponseRedirect, FileResponse
from django.shortcuts import render
-from xhtml2pdf import pisa
from django.template.loader import get_template
from io import BytesIO
+import pdfkit
# Create your views here.
@@ -30,15 +30,19 @@ def index(request):
if request.method == "POST":
document = Document.objects.get(id=request.POST["action"][1:])
+
+ if document.user != request.user:
+ return
+
if request.POST["action"][0] == 'f':
template = get_template('client/approve_doc_pdf.html')
context = {'doc': document}
html = template.render(context)
- result = BytesIO()
- pdf = pisa.pisaDocument(BytesIO(html.encode("ISO-8859-1")), result)
-
+ pdf = pdfkit.from_string(html, False)
+ result = BytesIO(pdf)
result.seek(0)
return FileResponse(result, as_attachment=True, filename=document.document_type.name+".pdf")
+
elif request.POST["action"][0] == 'a':
document.status = "ok"
document.save()
@@ -68,11 +72,13 @@ def index(request):
personal = None
medical = None
if i.document_type.personal_data:
- personal = i.personal_data.__dict__.values()
+ personal = i.personal_data
if i.document_type.medical_data:
- medical = i.medical_data.__dict__.values()
+ medical = i.medical_data
+
+ doc_group = i.user.groups.values_list('name', flat=True)[0]
- out.append([i, KeyVal.objects.filter(container=i), personal, medical])
+ out.append([i, KeyVal.objects.filter(container=i), personal, medical, doc_group])
context = {
"docs": out,
"empty": len(out) == 0,
diff --git a/documents_qtCfYLF b/documents_qtCfYLF
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/documents_qtCfYLF
diff --git a/manager/settings.py b/manager/settings.py
index 169c56e..087d7da 100644
--- a/manager/settings.py
+++ b/manager/settings.py
@@ -34,6 +34,7 @@ INSTALLED_APPS = [
'server.apps.ServerConfig',
'accounts.apps.AccountsConfig',
'client.apps.ClientConfig',
+ 'django_cleanup',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html
index 8a6be37..961b9ab 100644
--- a/server/templates/server/doc_list.html
+++ b/server/templates/server/doc_list.html
@@ -128,12 +128,19 @@
<span class="badge" data-badge-caption="">{{doc.0.user.first_name}} {{doc.0.user.last_name}}</span>
</div>
<div class="collapsible-body"><span>
+ {% if doc.0.status == "ok" or doc.0.status == 'archive' %}
+ <a class="waves-effect waves-light btn red lighten-1" onclick="send('f{{doc.0.id}}')"><i class="material-icons left">file_download</i> Scarica documento</a>
+ <br>
+ <br>
+ {% endif %}
<ul class="collapsible">
+ {% if doc.0.status == 'ok' or doc.0.status == 'archive' %}
<li>
<div class="collapsible-header">
- <i class="material-icons">confirmation_number</i>DEBUG {{doc.0.code}}
+ <i class="material-icons">confirmation_number</i>{{doc.0.code}}
</div>
</li>
+ {% endif %}
<li>
<div class="collapsible-header">
<i class="material-icons">send</i>{{doc.0.compilation_date}}
@@ -145,15 +152,64 @@
<i class="material-icons">person</i>Dati personali
</div>
<div class="collapsible-body"><span>
- <table class="striped">
- <tbody>
- {% for field in doc.2 %}
- <tr>
- <td>{{field}}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.0.user.first_name}}" id="first_name" type="text" >
+ <label for="first_name">Nome</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.0.user.last_name}}" id="last_name" type="text" >
+ <label for="last_name">Cognome</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.born_date}}" id="birth_date" type="text">
+ <label for="birth_date">Data di nascita</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.4}}" id="branca" type="text">
+ <label for="branca">Branca</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{doc.2.parent_name}}" id="parent_name" type="text" >
+ <label for="parent_name">Nome dei genitori</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input value="{{doc.2.via}}" disabled id="via" type="text" >
+ <label for="via">Via e numero</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.cap}}" name="cap" id="cap" type="text" >
+ <label for="cap">CAP</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.country}}" name="country" id="country" type="text" >
+ <label for="country">Paese</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.nationality}}" name="nationality" id="nationality" type="text" >
+ <label for="nationality">Nazionalit&agrave;</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.phone}}" name="phone" id="phone" type="text" >
+ <label for="phone">Cellulare</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.home_phone}}" name="home_phone" id="home_phone" type="text" >
+ <label for="home_phone">Telefono di casa</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.email}}" name="email" id="email" type="text" >
+ <label for="email">Email</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{doc.2.school}}" name="school" id="school" type="text" >
+ <label for="school">Scuola frequentata</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.2.year}}" name="year" id="year" type="text" >
+ <label for="year">Classe</label>
+ </div>
+ </div>
</span></div>
</li>
{% endif %}
@@ -163,15 +219,126 @@
<i class="material-icons">healing</i>Dati medici
</div>
<div class="collapsible-body"><span>
- <table class="striped">
- <tbody>
- {% for field in doc.3 %}
- <tr>
- <td>{{field}}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
+ <div class="row">
+ <div class="col s12">
+ <h6>Persona di contatto in caso di necessit&agrave;</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l6 s12">
+ <input disabled name="emer_name" value="{{doc.3.emer_name}}" id="emer_name" type="text" >
+ <label for="emer_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled name="emer_relative" value="{{doc.3.emer_relative}}" id="emer_relative" type="text" >
+ <label for="emer_releative">Parentela</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled name="cell_phone" value="{{doc.3.cell_phone}}" id="cellphone" type="text" >
+ <label for="cell_phone">Cellulare</label>
+ </div>
+ <div class="input-field col l9 s12">
+ <input disabled value="{{doc.3.address}}" name="address" id="address" type="text" >
+ <label for="address">Indirizzo completo</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input disabled value="{{doc.3.emer_phone}}" name="emer_phone" id="emer_phone" type="text" >
+ <label for="emer_phone">Telefono di casa</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Assicurazione</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.3.health_care}}" name="health_care" id="health_care" type="text" >
+ <label for="health_care">Cassa Malati</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.3.injuries}}" name="injuries" id="injuries" type="text" >
+ <label for="injuries">Infortuni</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.3.rc}}" name="rc" id="rc" type="text" >
+ <label for="rc">Responsabilit&agrave; civile</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="switch col s12">
+ &Egrave; sostenitore REGA&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="rega" type="checkbox" {% if doc.3.rega %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Medico di famiglia</h6>
+ </div>
+ <div class="input-field col l6 s12">
+ <input disabled value="{{doc.3.medic_name}}" name="medic_name" id="medic_name" type="text" >
+ <label for="medic_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l6 s12">
+ <input disabled value="{{doc.3.medic_phone}}" name="medic_phone" id="medic_phone" type="text" >
+ <label for="medic_phone">Telefono studio</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input disabled value="{{doc.3.medic_address}}" name="medic_address" id="medic_address" type="text" >
+ <label for="medic_address">Indirizzo completo</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Scheda medica personale</h6>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.3.sickness}}" name="sickness" id="sickness" type="text">
+ <label for="sickness">Principali malattie avute</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input disabled value="{{doc.3.vaccine}}" name="vaccine" id="vaccine" type="text">
+ <label for="vaccine">Vacinazioni fatte</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <label for="tetanus_date">Ultima vacinazione contro il tetano</label>
+ <input disabled value="{{doc.3.tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text">
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.3.allergy}}" name="allergy" id="allergy" type="text">
+ <label for="allergy">Allergie particolari/Intolleraze alimentari</label>
+ </div>
+ <div class="switch col s12">
+ Deve assumere regolarmente medicamenti&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="drugs_bool" type="checkbox" {% if doc.3.drugs_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.3.drugs}}" name="drugs" id="drugs" type="text">
+ <label for="drugs">Se s&igrave; quali, in che dosi e prescrizioni</label>
+ </div>
+ <div class="switch col s12">
+ Informazioni particolari sullo stato di salute: (postumi di operazioni, incidenti, malattie, disturbi fisici)&nbsp;&nbsp;
+ <label>
+ No
+ <input disabled name="misc_bool" type="checkbox" {% if doc.3.misc_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.3.misc}}" name="misc" id="misc" type="text">
+ <label for="misc">Se s&igrave; quali</label>
+ </div>
</span></div>
</li>
{% endif %}
diff --git a/server/templates/server/download_doc.html b/server/templates/server/download_doc.html
new file mode 100644
index 0000000..0f36372
--- /dev/null
+++ b/server/templates/server/download_doc.html
@@ -0,0 +1,265 @@
+{% extends 'registration/base_custom.html' %}
+
+{% block title %}Admin - Documenti{% endblock %}
+
+{% block content %}
+<ul class="collapsible">
+ <li class="active">
+ <div class="collapsible-header">
+ {% if doc.0.status == "wait" %}
+ <i class="material-icons">timelapse</i>
+ {% elif doc.0.status == "ok" %}
+ <i class="material-icons">check</i>
+ {% elif doc.0.status == "archive" %}
+ <i class="material-icons">archive</i>
+ {% elif doc.0.status == "autosign" %}
+ <i class="material-icons">assignment_turned_in</i>
+ {% endif %}
+ {{doc.0.document_type.name}}
+ <span class="badge" data-badge-caption="">{{doc.0.compilation_date}}</span>
+ </div>
+ <div class="collapsible-body"><span>
+ <ul class="collapsible">
+ {% if doc.0.status == 'ok' or doc.0.status == 'archive' %}
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">confirmation_number</i>{{doc.0.code}}
+ </div>
+ </li>
+ {% endif %}
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">send</i>{{doc.0.compilation_date}}
+ </div>
+ </li>
+ {% if doc.0.document_type.personal_data %}
+ <li class="active">
+ <div class="collapsible-header">
+ <i class="material-icons">person</i>Dati personali
+ </div>
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input value="{{doc.0.user.first_name}}" id="first_name" type="text" >
+ <label for="first_name">Nome</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.0.user.last_name}}" id="last_name" type="text" >
+ <label for="last_name">Cognome</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.2.born_date}}" id="birth_date" type="text">
+ <label for="birth_date">Data di nascita</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.4}}" id="branca" type="text">
+ <label for="branca">Branca</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input value="{{doc.2.parent_name}}" id="parent_name" type="text" >
+ <label for="parent_name">Nome dei genitori</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input value="{{doc.2.via}}" id="via" type="text" >
+ <label for="via">Via e numero</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.2.cap}}" name="cap" id="cap" type="text" >
+ <label for="cap">CAP</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.2.country}}" name="country" id="country" type="text" >
+ <label for="country">Paese</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.2.nationality}}" name="nationality" id="nationality" type="text" >
+ <label for="nationality">Nazionalit&agrave;</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.2.phone}}" name="phone" id="phone" type="text" >
+ <label for="phone">Cellulare</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.2.home_phone}}" name="home_phone" id="home_phone" type="text" >
+ <label for="home_phone">Telefono di casa</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.2.email}}" name="email" id="email" type="text" >
+ <label for="email">Email</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input value="{{doc.2.school}}" name="school" id="school" type="text" >
+ <label for="school">Scuola frequentata</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.2.year}}" name="year" id="year" type="text" >
+ <label for="year">Classe</label>
+ </div>
+ </div>
+ </span></div>
+ </li>
+ {% endif %}
+ {% if doc.0.document_type.medical_data %}
+ <li class="active">
+ <div class="collapsible-header">
+ <i class="material-icons">healing</i>Dati medici
+ </div>
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="col s12">
+ <h6>Persona di contatto in caso di necessit&agrave;</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l6 s12">
+ <input name="emer_name" value="{{doc.3.emer_name}}" id="emer_name" type="text" >
+ <label for="emer_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input name="emer_relative" value="{{doc.3.emer_relative}}" id="emer_relative" type="text" >
+ <label for="emer_releative">Parentela</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input name="cell_phone" value="{{doc.3.cell_phone}}" id="cellphone" type="text" >
+ <label for="cell_phone">Cellulare</label>
+ </div>
+ <div class="input-field col l9 s12">
+ <input value="{{doc.3.address}}" name="address" id="address" type="text" >
+ <label for="address">Indirizzo completo</label>
+ </div>
+ <div class="input-field col l3 s12">
+ <input value="{{doc.3.emer_phone}}" name="emer_phone" id="emer_phone" type="text" >
+ <label for="emer_phone">Telefono di casa</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Assicurazione</h6>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col l4 s12">
+ <input value="{{doc.3.health_care}}" name="health_care" id="health_care" type="text" >
+ <label for="health_care">Cassa Malati</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.3.injuries}}" name="injuries" id="injuries" type="text" >
+ <label for="injuries">Infortuni</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input value="{{doc.3.rc}}" name="rc" id="rc" type="text" >
+ <label for="rc">Responsabilit&agrave; civile</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="switch col s12">
+ &Egrave; sostenitore REGA&nbsp;&nbsp;
+ <label>
+ No
+ <input name="rega" type="checkbox" {% if doc.3.rega %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Medico di famiglia</h6>
+ </div>
+ <div class="input-field col l6 s12">
+ <input value="{{doc.3.medic_name}}" name="medic_name" id="medic_name" type="text" >
+ <label for="medic_name">Nome e cognome</label>
+ </div>
+ <div class="input-field col l6 s12">
+ <input value="{{doc.3.medic_phone}}" name="medic_phone" id="medic_phone" type="text" >
+ <label for="medic_phone">Telefono studio</label>
+ </div>
+ <div class="input-field col l12 s12">
+ <input value="{{doc.3.medic_address}}" name="medic_address" id="medic_address" type="text" >
+ <label for="medic_address">Indirizzo completo</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <h6>Scheda medica personale</h6>
+ </div>
+ <div class="input-field col s12">
+ <input value="{{doc.3.sickness}}" name="sickness" id="sickness" type="text">
+ <label for="sickness">Principali malattie avute</label>
+ </div>
+ <div class="input-field col l8 s12">
+ <input value="{{doc.3.vaccine}}" name="vaccine" id="vaccine" type="text">
+ <label for="vaccine">Vacinazioni fatte</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <label for="tetanus_date">Ultima vacinazione contro il tetano</label>
+ <input value="{{doc.3.tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text">
+ </div>
+ <div class="input-field col s12">
+ <input value="{{doc.3.allergy}}" name="allergy" id="allergy" type="text">
+ <label for="allergy">Allergie particolari/Intolleraze alimentari</label>
+ </div>
+ <div class="switch col s12">
+ Deve assumere regolarmente medicamenti&nbsp;&nbsp;
+ <label>
+ No
+ <input name="drugs_bool" type="checkbox" {% if doc.3.drugs_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input value="{{doc.3.drugs}}" name="drugs" id="drugs" type="text">
+ <label for="drugs">Se s&igrave; quali, in che dosi e prescrizioni</label>
+ </div>
+ <div class="switch col s12">
+ Informazioni particolari sullo stato di salute: (postumi di operazioni, incidenti, malattie, disturbi fisici)&nbsp;&nbsp;
+ <label>
+ No
+ <input name="misc_bool" type="checkbox" {% if doc.3.misc_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input value="{{doc.3.misc}}" name="misc" id="misc" type="text">
+ <label for="misc">Se s&igrave; quali</label>
+ </div>
+ </span></div>
+ </li>
+ {% endif %}
+ {% if doc.0.document_type.custom_data %}
+ <li class="active">
+ <div class="collapsible-header">
+ <i class="material-icons">add_circle_outline</i>Dati aggiuntivi
+ </div>
+ <div class="collapsible-body"><span>
+ <table class="striped">
+ <tbody>
+ {% for key in doc.1 %}
+ <tr>
+ <td>{{key.key}}</td>
+ <td>{{key.value}}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </span></div>
+ </li>
+ {% endif %}
+ </ul>
+ </span></div>
+ </li>
+</ul>
+</form>
+{% endblock %}
+
+{%block script%}
+document.addEventListener('DOMContentLoaded', function() {
+ var elems = document.querySelectorAll('.collapsible');
+ var options = {
+ accordion: false
+ }
+ var instances = M.Collapsible.init(elems, options);
+ });
+{% endblock %} \ No newline at end of file
diff --git a/server/views.py b/server/views.py
index 296dae4..fb6af0f 100644
--- a/server/views.py
+++ b/server/views.py
@@ -2,13 +2,16 @@ from django.shortcuts import render
from client.models import UserCode, Keys, DocumentType, Document, KeyVal
from django.contrib.auth.models import Group, Permission, User
from django.db.models import Q
-from django.http import HttpResponseRedirect
+from django.http import HttpResponseRedirect, FileResponse
from django.db.models.deletion import ProtectedError
+from django.template.loader import get_template
import dateparser
from datetime import datetime
from datetime import timedelta
import pytz
+import pdfkit
+from io import BytesIO
# Create your views here.
@@ -364,6 +367,9 @@ def doccreate(request):
def doclist(request):
context = {}
if request.user.is_staff:
+ parent_group = request.user.groups.values_list('name', flat=True)[
+ 0]
+ group = Group.objects.get(name=parent_group)
zurich = pytz.timezone('Europe/Zurich')
error = False
error_text = ""
@@ -385,6 +391,19 @@ def doclist(request):
chips_types = []
if request.method == "POST":
+ if request.POST["action"][0] == 'f':
+ document = Document.objects.get(id=request.POST["action"][1:])
+ if document.group == group:
+ template = get_template('server/download_doc.html')
+ doc = [document, KeyVal.objects.filter(container=document), document.personal_data, document.medical_data, parent_group]
+ context = {'doc': doc}
+ html = template.render(context)
+ pdf = pdfkit.from_string(html, False)
+ result = BytesIO(pdf)
+ result.seek(0)
+
+ return FileResponse(result, as_attachment=True, filename=document.user.username+"_"+document.document_type.name+".pdf")
+
selected = []
for i in request.POST.keys():
if i.isdigit():
@@ -430,9 +449,6 @@ def doclist(request):
owner = []
types = []
- 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:
@@ -474,11 +490,13 @@ def doclist(request):
personal = None
medical = None
if i.document_type.personal_data:
- personal = i.personal_data.__dict__.values()
+ personal = i.personal_data
if i.document_type.medical_data:
- medical = i.medical_data.__dict__.values()
+ medical = i.medical_data
- out.append([i, KeyVal.objects.filter(container=i), personal, medical])
+ doc_group = i.user.groups.values_list('name', flat=True)[0]
+
+ out.append([i, KeyVal.objects.filter(container=i), personal, medical, doc_group])
auto_types = DocumentType.objects.filter(Q(group_private=False) | Q(group=group))
users = User.objects.filter(groups__name=parent_group)
@@ -499,4 +517,4 @@ def doclist(request):
}
return render(request, 'server/doc_list.html', context)
else:
- return render(request, 'client/index.html', context)
+ return render(request, 'client/index.html', context) \ No newline at end of file
diff --git a/templates/registration/base_client.html b/templates/registration/base_client.html
new file mode 100644
index 0000000..6a0da38
--- /dev/null
+++ b/templates/registration/base_client.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <meta charset="utf-8">
+ <title>{% block title %}Scout Brega{% endblock %}</title>
+</head>
+<body>
+ <nav>
+ <div class="nav-wrapper teal">
+ {% block nav %}
+ {% endblock %}
+ <ul class="right">
+ {% if user.is_staff %}
+ <li><a href="{% url 'server' %}">Pannello Admin</a></li>
+ {% endif %}
+ {% if user.is_authenticated %}
+ <li><a class="tooltipped" data-position="bottom" data-tooltip="Preferenze" href="{% url 'personal' %}">{{ user.username }}</a></li>
+ {% endif %}
+ {% if user.username != "" %}
+ <li>
+ <a class="tooltipped" data-position="bottom" data-tooltip="Logout" href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a>
+ </li>
+ {% else %}
+ <li><a href="{% url 'signup' %}">Registrazione</a></li>
+ <li><a href="{% url 'login' %}">Login</a></li>
+ {% endif %}
+ </ul>
+ </div>
+ </nav>
+ <main style="margin-left: 10px;margin-right: 10px;margin-top: 10px;">
+ {% block content %}
+ {% endblock %}
+ </main>
+ <script
+ src="https://code.jquery.com/jquery-3.5.1.min.js"
+ integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
+ crossorigin="anonymous"></script>
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
+ <script>
+ document.addEventListener('DOMContentLoaded', function() {
+ var elems = document.querySelectorAll('.tooltipped');
+ var instances = M.Tooltip.init(elems, {});
+ });
+ {% block script %}
+ {% endblock%}
+ </script>
+</body>
+</html> \ No newline at end of file