diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | server/templates/server/doc_list.html | 125 | ||||
-rw-r--r-- | server/templates/server/doc_list_readonly.html | 131 | ||||
-rw-r--r-- | server/views.py | 169 | ||||
-rw-r--r-- | version.txt | 2 |
5 files changed, 191 insertions, 237 deletions
@@ -5,3 +5,4 @@ apikey.sh db.sqlite3 documents* .commit +.vscode/** diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html index fd90f12..74024e7 100644 --- a/server/templates/server/doc_list.html +++ b/server/templates/server/doc_list.html @@ -32,6 +32,7 @@ {% endblock %} {% block content %} +{% load app_filter %} <div id="modal2" class="modal"> <div class="modal-content"> @@ -144,51 +145,51 @@ <li> <div class="collapsible-header"> <label> - <input name={{doc.0.id}} type="checkbox" class="filled-in allselect"/> + <input name={{doc.id}} type="checkbox" class="filled-in allselect"/> <span></span> </label> - {% if doc.0.status == "wait" %} + {% if doc.status == "wait" %} <i class="material-icons">timelapse</i> - {% elif doc.0.status == "ok" %} - {% if doc.0.signed_doc %} + {% elif doc.status == "ok" %} + {% if doc.signed_doc %} <i class="material-icons">check_circle</i> {% else %} <i class="material-icons">check</i> {% endif %} - {% elif doc.0.status == "archive" %} + {% elif doc.status == "archive" %} <i class="material-icons">archive</i> - {% elif doc.0.status == "autosign" %} + {% elif doc.status == "autosign" %} <i class="material-icons">assignment_turned_in</i> {% endif %} {% if settings.DEBUG %} - {{doc.0.id}}: + {{doc.id}}: {% endif %} - {{doc.0.document_type.name}} - <span class="badge" data-badge-caption="">{{doc.0.user.first_name}} {{doc.0.user.last_name}}</span> + {{doc.document_type.name}} + <span class="badge" data-badge-caption="">{{doc.user.first_name}} {{doc.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 {{color}}" onclick="send('k{{doc.0.id}}')"><i class="material-icons left">file_download</i> Scarica documento</a> + {% if doc.status == "ok" or doc.status == 'archive' %} + <a class="waves-effect waves-light btn {{color}}" onclick="send('k{{doc.id}}')"><i class="material-icons left">file_download</i> Scarica documento</a> <br> <br> {% endif %} <ul class="collection"> - {% if doc.0.status == 'ok' or doc.0.status == 'archive' %} + {% if doc.status == 'ok' or doc.status == 'archive' %} <li class="collection-item"> - <i class="material-icons left">confirmation_number</i>{{doc.0.code}} + <i class="material-icons left">confirmation_number</i>{{doc.code}} </li> {% endif %} - {% if doc.0.document_type.custom_group %} + {% if doc.document_type.custom_group %} <li class="collection-item"> - <i class="material-icons left">group_work</i>{{doc.0.group.name}} + <i class="material-icons left">group_work</i>{{doc.group.name}} </li> {% endif %} <li class="collection-item"> - <i class="material-icons left">send</i>{{doc.0.compilation_date}} + <i class="material-icons left">send</i>{{doc.compilation_date}} </li> </ul> <ul class="collapsible"> - {% if doc.0.document_type.personal_data %} + {% if doc.document_type.personal_data %} <li> <div class="collapsible-header"> <i class="material-icons">person</i>Dati personali @@ -196,79 +197,79 @@ <div class="collapsible-body"><span> <div class="row"> <div class="input-field col l4 s12"> - <input disabled value="{{doc.0.user.first_name}}" id="first_name" type="text" > + <input disabled value="{{doc.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" > + <input disabled value="{{doc.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"> + <input disabled value="{{doc.personal_data.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"> + <input disabled value="{{base_group}}" id="branca" type="text"> <label for="branca">Branca</label> </div> <div class="input-field col l4 s12"> - <input disabled value="{{doc.2.parent_name}}" id="parent_name" type="text" > + <input disabled value="{{doc.personal_data.parent_name}}" id="parent_name" type="text" > <label for="parent_name">Nome dei genitori</label> </div> <div class="input-field col l4 s12"> - <input disabled value="{{doc.2.avs_number}}" id="avs_number" type="text"> + <input disabled value="{{doc.personal_data.avs_number}}" id="avs_number" type="text"> <label for="avs_number">Numero AVS</label> </div> <div class="input-field col l12 s12"> - <input value="{{doc.2.via}}" disabled id="via" type="text" > + <input value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.nationality}}" name="nationality" id="nationality" type="text" > <label for="nationality">Nazionalità</label> </div> <div class="input-field col l4 s12"> - <input disabled value="{{doc.2.phone}}" name="phone" id="phone" type="text" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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 %} + {% if doc.document_type.medical_data %} <li> <div class="collapsible-header"> - {% if doc.0.medical_data %} + {% if doc.medical_data %} <i class="material-icons">healing</i>Dati medici {% else %} <i class="material-icons">healing</i><del>Dati medici</del> {% endif %} </div> - {% if doc.0.medical_data %} + {% if doc.medical_data %} <div class="collapsible-body"><span> <div class="row"> <div class="col s12"> @@ -277,23 +278,23 @@ </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" > + <input disabled name="emer_name" value="{{doc.medical_data.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" > + <input disabled name="emer_relative" value="{{doc.medical_data.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" > + <input disabled name="cell_phone" value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.emer_phone}}" name="emer_phone" id="emer_phone" type="text" > <label for="emer_phone">Telefono di casa</label> </div> </div> @@ -304,15 +305,15 @@ </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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.rc}}" name="rc" id="rc" type="text" > <label for="rc">Responsabilità civile</label> </div> </div> @@ -321,7 +322,7 @@ È sostenitore REGA <label> No - <input disabled name="rega" type="checkbox" {% if doc.3.rega %}checked="checked"{%endif%}> + <input disabled name="rega" type="checkbox" {% if doc.medical_data.rega %}checked="checked"{%endif%}> <span class="lever"></span> Si </label> @@ -332,15 +333,15 @@ <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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.medic_address}}" name="medic_address" id="medic_address" type="text" > <label for="medic_address">Indirizzo completo</label> </div> </div> @@ -349,52 +350,52 @@ <h6>Scheda medica personale</h6> </div> <div class="input-field col s12"> - <input disabled value="{{doc.3.sickness}}" name="sickness" id="sickness" type="text"> + <input disabled value="{{doc.medical_data.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"> + <input disabled value="{{doc.medical_data.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"> + <input disabled value="{{doc.medical_data.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"> + <input disabled value="{{doc.medical_data.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 <label> No - <input disabled name="drugs_bool" type="checkbox" {% if doc.3.drugs_bool %}checked="checked"{%endif%}> + <input disabled name="drugs_bool" type="checkbox" {% if doc.medical_data.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"> + <input disabled value="{{doc.medical_data.drugs}}" name="drugs" id="drugs" type="text"> <label for="drugs">Se sì 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) <label> No - <input disabled name="misc_bool" type="checkbox" {% if doc.3.misc_bool %}checked="checked"{%endif%}> + <input disabled name="misc_bool" type="checkbox" {% if doc.medical_data.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"> + <input disabled value="{{doc.medical_data.misc}}" name="misc" id="misc" type="text"> <label for="misc">Se sì quali</label> </div> </span></div> {% endif %} </li> {% endif %} - {% if doc.0.document_type.custom_data %} + {% if doc.document_type.custom_data %} <li> <div class="collapsible-header"> <i class="material-icons">add_circle_outline</i>Dati aggiuntivi @@ -402,7 +403,7 @@ <div class="collapsible-body"><span> <table class="striped"> <tbody> - {% for key in doc.1 %} + {% for key in doc|doc_key %} <tr> <td>{{key.key}}</td> <td>{{key.value}}</td> @@ -413,7 +414,6 @@ </span></div> </li> {% endif %} - {% if doc.0.document_type.medical_data %} <li> <div class="collapsible-header"> <i class="material-icons">attach_file</i>Allegati @@ -423,16 +423,17 @@ <div class="col s12"> <div class="card"> <div class="card-image"> - {% if doc.5 %}<img class="lazyload" data-src="{{ doc.5 }}">{% endif %} + {% if doc.signed_doc %} <img class="lazyload" data-src="{{ sign_doc_file.0 }}{{ doc.id }}{{ sign_doc_file.1 }}"> {% endif %} </div> </div> </div> </div> + {% if doc.medical_data %} <div class="row"> <div class="col s12"> <div class="card"> <div class="card-image"> - {% if doc.6 %}<img class="lazyload" data-src="{{ doc.6 }}">{% endif %} + {% if doc.medical_data.health_care_certificate %}<img class="lazyload" data-src="{{ health_file.0 }}{{ doc.id }}{{ health_file.1}}">{% endif %} </div> </div> </div> @@ -441,14 +442,14 @@ <div class="col s12"> <div class="card"> <div class="card-image"> - {% if doc.7 %}<img class="lazyload" data-src="{{ doc.7 }}">{% endif %} + {% if doc.medical_data.vac_certificate %}<img class="lazyload" data-src="{{ vac_file.0 }}{{ doc.id }}{{ vac_file.1}}">{% endif %} </div> </div> </div> </div> + {% endif %} </span></div> </li> - {% endif %} </ul> </span></div> </li> diff --git a/server/templates/server/doc_list_readonly.html b/server/templates/server/doc_list_readonly.html index 42a52e8..0ed1650 100644 --- a/server/templates/server/doc_list_readonly.html +++ b/server/templates/server/doc_list_readonly.html @@ -26,6 +26,7 @@ {% endblock %} {% block content %} +{% load app_filter %} <div id="modal3" class="modal"> <div class="modal-content"> @@ -125,51 +126,51 @@ <li> <div class="collapsible-header"> <label> - <input name={{doc.0.id}} type="checkbox" class="filled-in allselect"/> + <input name={{doc.id}} type="checkbox" class="filled-in allselect"/> <span></span> </label> - {% if doc.0.status == "wait" %} + {% if doc.status == "wait" %} <i class="material-icons">timelapse</i> - {% elif doc.0.status == "ok" %} - {% if doc.0.signed_doc %} + {% elif doc.status == "ok" %} + {% if doc.signed_doc %} <i class="material-icons">check_circle</i> {% else %} <i class="material-icons">check</i> {% endif %} - {% elif doc.0.status == "archive" %} + {% elif doc.status == "archive" %} <i class="material-icons">archive</i> - {% elif doc.0.status == "autosign" %} + {% elif doc.status == "autosign" %} <i class="material-icons">assignment_turned_in</i> {% endif %} {% if settings.DEBUG %} - {{doc.0.id}}: + {{doc.id}}: {% endif %} - {{doc.0.document_type.name}} - <span class="badge" data-badge-caption="">{{doc.0.user.first_name}} {{doc.0.user.last_name}}</span> + {{doc.document_type.name}} + <span class="badge" data-badge-caption="">{{doc.user.first_name}} {{doc.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 {{color}}" onclick="send('k{{doc.0.id}}')"><i class="material-icons left">file_download</i> Scarica documento</a> + {% if doc.status == "ok" or doc.status == 'archive' %} + <a class="waves-effect waves-light btn {{color}}" onclick="send('k{{doc.id}}')"><i class="material-icons left">file_download</i> Scarica documento</a> <br> <br> {% endif %} <ul class="collection"> - {% if doc.0.status == 'ok' or doc.0.status == 'archive' %} + {% if doc.status == 'ok' or doc.status == 'archive' %} <li class="collection-item"> - <i class="material-icons left">confirmation_number</i>{{doc.0.code}} + <i class="material-icons left">confirmation_number</i>{{doc.code}} </li> {% endif %} - {% if doc.0.document_type.custom_group %} + {% if doc.document_type.custom_group %} <li class="collection-item"> - <i class="material-icons left">group_work</i>{{doc.0.group.name}} + <i class="material-icons left">group_work</i>{{doc.group.name}} </li> {% endif %} <li class="collection-item"> - <i class="material-icons left">send</i>{{doc.0.compilation_date}} + <i class="material-icons left">send</i>{{doc.compilation_date}} </li> </ul> <ul class="collapsible"> - {% if doc.0.document_type.personal_data %} + {% if doc.document_type.personal_data %} <li> <div class="collapsible-header"> <i class="material-icons">person</i>Dati personali @@ -177,75 +178,79 @@ <div class="collapsible-body"><span> <div class="row"> <div class="input-field col l4 s12"> - <input disabled value="{{doc.0.user.first_name}}" id="first_name" type="text" > + <input disabled value="{{doc.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" > + <input disabled value="{{doc.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"> + <input disabled value="{{doc.personal_data.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"> + <input disabled value="{{base_group}}" 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" > + <div class="input-field col l4 s12"> + <input disabled value="{{doc.personal_data.parent_name}}" id="parent_name" type="text" > <label for="parent_name">Nome dei genitori</label> </div> + <div class="input-field col l4 s12"> + <input disabled value="{{doc.personal_data.avs_number}}" id="avs_number" type="text"> + <label for="avs_number">Numero AVS</label> + </div> <div class="input-field col l12 s12"> - <input value="{{doc.2.via}}" disabled id="via" type="text" > + <input value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.nationality}}" name="nationality" id="nationality" type="text" > <label for="nationality">Nazionalità</label> </div> <div class="input-field col l4 s12"> - <input disabled value="{{doc.2.phone}}" name="phone" id="phone" type="text" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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" > + <input disabled value="{{doc.personal_data.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 %} + {% if doc.document_type.medical_data %} <li> <div class="collapsible-header"> - {% if doc.0.medical_data %} + {% if doc.medical_data %} <i class="material-icons">healing</i>Dati medici {% else %} <i class="material-icons">healing</i><del>Dati medici</del> {% endif %} </div> - {% if doc.0.medical_data %} + {% if doc.medical_data %} <div class="collapsible-body"><span> <div class="row"> <div class="col s12"> @@ -254,23 +259,23 @@ </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" > + <input disabled name="emer_name" value="{{doc.medical_data.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" > + <input disabled name="emer_relative" value="{{doc.medical_data.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" > + <input disabled name="cell_phone" value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.emer_phone}}" name="emer_phone" id="emer_phone" type="text" > <label for="emer_phone">Telefono di casa</label> </div> </div> @@ -281,15 +286,15 @@ </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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.rc}}" name="rc" id="rc" type="text" > <label for="rc">Responsabilità civile</label> </div> </div> @@ -298,7 +303,7 @@ È sostenitore REGA <label> No - <input disabled name="rega" type="checkbox" {% if doc.3.rega %}checked="checked"{%endif%}> + <input disabled name="rega" type="checkbox" {% if doc.medical_data.rega %}checked="checked"{%endif%}> <span class="lever"></span> Si </label> @@ -309,15 +314,15 @@ <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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.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" > + <input disabled value="{{doc.medical_data.medic_address}}" name="medic_address" id="medic_address" type="text" > <label for="medic_address">Indirizzo completo</label> </div> </div> @@ -326,52 +331,52 @@ <h6>Scheda medica personale</h6> </div> <div class="input-field col s12"> - <input disabled value="{{doc.3.sickness}}" name="sickness" id="sickness" type="text"> + <input disabled value="{{doc.medical_data.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"> + <input disabled value="{{doc.medical_data.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"> + <input disabled value="{{doc.medical_data.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"> + <input disabled value="{{doc.medical_data.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 <label> No - <input disabled name="drugs_bool" type="checkbox" {% if doc.3.drugs_bool %}checked="checked"{%endif%}> + <input disabled name="drugs_bool" type="checkbox" {% if doc.medical_data.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"> + <input disabled value="{{doc.medical_data.drugs}}" name="drugs" id="drugs" type="text"> <label for="drugs">Se sì 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) <label> No - <input disabled name="misc_bool" type="checkbox" {% if doc.3.misc_bool %}checked="checked"{%endif%}> + <input disabled name="misc_bool" type="checkbox" {% if doc.medical_data.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"> + <input disabled value="{{doc.medical_data.misc}}" name="misc" id="misc" type="text"> <label for="misc">Se sì quali</label> </div> </span></div> {% endif %} </li> {% endif %} - {% if doc.0.document_type.custom_data %} + {% if doc.document_type.custom_data %} <li> <div class="collapsible-header"> <i class="material-icons">add_circle_outline</i>Dati aggiuntivi @@ -379,7 +384,7 @@ <div class="collapsible-body"><span> <table class="striped"> <tbody> - {% for key in doc.1 %} + {% for key in doc|doc_key %} <tr> <td>{{key.key}}</td> <td>{{key.value}}</td> @@ -390,7 +395,6 @@ </span></div> </li> {% endif %} - {% if doc.0.document_type.medical_data %} <li> <div class="collapsible-header"> <i class="material-icons">attach_file</i>Allegati @@ -400,16 +404,17 @@ <div class="col s12"> <div class="card"> <div class="card-image"> - {% if doc.5 %}<img class="lazyload" data-src="{{ doc.5 }}">{% endif %} + {% if doc.signed_doc %} <img class="lazyload" data-src="{{ sign_doc_file.0 }}{{ doc.id }}{{ sign_doc_file.1 }}"> {% endif %} </div> </div> </div> </div> + {% if doc.medical_data %} <div class="row"> <div class="col s12"> <div class="card"> <div class="card-image"> - {% if doc.6 %}<img class="lazyload" data-src="{{ doc.6 }}">{% endif %} + {% if doc.medical_data.health_care_certificate %}<img class="lazyload" data-src="{{ health_file.0 }}{{ doc.id }}{{ health_file.1}}">{% endif %} </div> </div> </div> @@ -418,14 +423,14 @@ <div class="col s12"> <div class="card"> <div class="card-image"> - {% if doc.7 %}<img class="lazyload" data-src="{{ doc.7 }}">{% endif %} + {% if doc.medical_data.vac_certificate %}<img class="lazyload" data-src="{{ vac_file.0 }}{{ doc.id }}{{ vac_file.1}}">{% endif %} </div> </div> </div> </div> + {% endif %} </span></div> </li> - {% endif %} </ul> </span></div> </li> @@ -484,7 +489,7 @@ $('#chips_owner').chips({ autocompleteOptions: { data: { {% for user in users %} - '{{user.username}} ({{user.first_name}} {{user.last_name}})': null, + '{{user.user__username}} ({{user.user__first_name}} {{user.user__last_name}})': null, {% endfor %} }, limit: Infinity, diff --git a/server/views.py b/server/views.py index 0cdcf2a..a15d8bc 100644 --- a/server/views.py +++ b/server/views.py @@ -972,83 +972,51 @@ def doclist(request): types = []
groups = []
- # filter documents based on group of staff
- q_obj = Q(group__name__in=parent_groups)
-
- documents = Document.objects.filter(q_obj)
+ # filter documents based on group of staff and date range
+ q_obj = Q(group__name__in=parent_groups) & Q(compilation_date__range=[newer, older])
# filter documents
if not hidden:
- documents = documents.filter(~Q(status="archive"))
+ q_obj &= ~Q(status="archive")
hidden_check = ""
if not wait:
- documents = documents.filter(~Q(status="wait"))
+ q_obj &= ~Q(status="wait")
wait_check = ""
if not selfsign:
- documents = documents.filter(~Q(status="autosign"))
+ q_obj &= ~Q(status="autosign")
selfsign_check = ""
if not ok:
- documents = documents.filter(~Q(status="ok"))
+ q_obj &= ~Q(status="ok")
ok_check = ""
- if not signdoc:
+ if signdoc:
+ q_obj &= ~Q(signed_doc="")
+ else:
signdoc_check = ""
- # filter date range
- documents = documents.filter(compilation_date__range=[newer, older])
-
# filter types, owner, groups using chips
if len(types) > 0:
if types[0] != "":
- q_obj = Q(document_type__name__in=types)
+ q_obj &= Q(document_type__name__in=types)
chips_types += types
- documents = documents.filter(q_obj)
if len(owner) > 0:
if owner[0] != "":
- q_obj = Q(user__username__in=list(map(lambda x: x.split("(")[0][:-1], owner)))
+ q_obj &= Q(user__username__in=list(map(lambda x: x.split("(")[0][:-1], owner)))
chips_owner += owner
- documents = documents.filter(q_obj)
if len(groups) > 0:
if groups[0] != "":
- q_obj = Q(group__name__in=groups)
+ q_obj &= Q(group__name__in=groups)
chips_groups += groups
- documents = documents.filter(q_obj)
-
- out = []
- users = []
-
- # TODO convert this in a query
- for i in documents:
- # filter for confirmed with attachment documents and approved
- if signdoc:
- if i.status == "ok" and not i.signed_doc:
- continue
-
- # prepare images in base64
- personal = None
- medical = None
- vac_file = ""
- health_file = ""
- sign_doc_file = ""
- if i.personal_data:
- personal = i.personal_data
- if i.medical_data:
- medical = i.medical_data
- if medical.vac_certificate.name:
- vac_file = "/server/media/" + str(i.id) + "/vac_certificate/doc"
-
- if medical.health_care_certificate.name:
- health_file = "/server/media/" + str(i.id) + "/health_care_certificate/doc"
- if i.signed_doc:
- sign_doc_file = "/server/media/" + str(i.id) + "/signed_doc/doc"
+ # run query
+ documents = Document.objects.filter(q_obj).select_related("personal_data", "medical_data", "document_type", "user")
- doc_group = i.user.groups.values_list('name', flat=True)[0]
+ users = documents.values("user__username", "user__first_name", "user__last_name")
- out.append([i, KeyVal.objects.filter(container=i), personal,
- medical, doc_group, vac_file, health_file, sign_doc_file])
- users.append(i.user)
+ vac_file = ["/server/media/", "/vac_certificate/doc"]
+ health_file = ["/server/media/", "/health_care_certificate/doc"]
+ sign_doc_file = ["/server/media/", "/signed_doc/doc"]
# get types and users for chips autocompletation
if request.user.is_staff:
@@ -1058,10 +1026,13 @@ def doclist(request): auto_types = DocumentType.objects.filter(Q(group_private=False))
context = {
+ "vac_file": vac_file,
+ "health_file": health_file,
+ "sign_doc_file": sign_doc_file,
"types": auto_types,
"users": users,
"groups": parent_groups,
- "docs": out,
+ "docs": documents,
"hidden_check": hidden_check,
"wait_check": wait_check,
"selfsign_check": selfsign_check,
@@ -1113,13 +1084,14 @@ def doclist_readonly(request): # get all users that are part of the group and are administrators but not request.user
emails = User.objects.filter(groups__name=i).filter(Q(is_staff=True) | Q(user_permissions=perm)).filter(~Q(id=request.user.id)).values_list("email", flat=True)
- send_mail(
- 'Attenzione! ' + request.user.username + ' ha visionato i documenti del gruppo "' + i.name + '"',
- "Questo messaggio è stato inviato automaticamente dal sistema di iscrizioni digitali. Ti è arrivata questa mail perchè hai abilitato la possibilità a persone del gruppo capi di visionare i documenti. L'utente con username " + request.user.username + " e con nome registrato " + request.user.first_name + " " + request.user.last_name + " ha visionato dei documenti.",
- settings.DEFAULT_FROM_EMAIL,
- emails,
- fail_silently=False,
- )
+ if not settings.DEBUG:
+ send_mail(
+ 'Attenzione! ' + request.user.username + ' ha visionato i documenti del gruppo "' + i.name + '"',
+ "Questo messaggio è stato inviato automaticamente dal sistema di iscrizioni digitali. Ti è arrivata questa mail perchè hai abilitato la possibilità a persone del gruppo capi di visionare i documenti. L'utente con username " + request.user.username + " e con nome registrato " + request.user.first_name + " " + request.user.last_name + " ha visionato dei documenti.",
+ settings.DEFAULT_FROM_EMAIL,
+ emails,
+ fail_silently=False,
+ )
# create typezone
@@ -1227,90 +1199,64 @@ def doclist_readonly(request): types = []
groups = []
- # filter documents based on group of staff
- documents = Document.objects.filter(group__in=groups_view)
+ # filter documents based on group of staff and date range
+ q_obj = Q(group__name__in=groups_view) & Q(compilation_date__range=[newer, older])
# filter documents
if not hidden:
- documents = documents.filter(~Q(status="archive"))
+ q_obj &= ~Q(status="archive")
hidden_check = ""
if not wait:
- documents = documents.filter(~Q(status="wait"))
+ q_obj &= ~Q(status="wait")
wait_check = ""
if not selfsign:
- documents = documents.filter(~Q(status="autosign"))
+ q_obj &= ~Q(status="autosign")
selfsign_check = ""
if not ok:
- documents = documents.filter(~Q(status="ok"))
+ q_obj &= ~Q(status="ok")
ok_check = ""
- if not signdoc:
+ if signdoc:
+ q_obj &= ~Q(signed_doc="")
+ else:
signdoc_check = ""
- # filter date range
- documents = documents.filter(compilation_date__range=[newer, older])
-
# filter types, owner, groups using chips
if len(types) > 0:
if types[0] != "":
- q_obj = Q(document_type__name__in=types)
+ q_obj &= Q(document_type__name__in=types)
chips_types += types
- documents = documents.filter(q_obj)
if len(owner) > 0:
if owner[0] != "":
- q_obj = Q(user__username__in=list(map(lambda x: x.split("(")[0][:-1], owner)))
+ q_obj &= Q(user__username__in=list(map(lambda x: x.split("(")[0][:-1], owner)))
chips_owner += owner
- documents = documents.filter(q_obj)
if len(groups) > 0:
if groups[0] != "":
- q_obj = Q(group__name__in=groups)
+ q_obj &= Q(group__name__in=groups)
chips_groups += groups
- documents = documents.filter(q_obj)
- out = []
- users = []
- # TODO user query instead of for
- for i in documents:
- # filter for confirmed with attachment documents and approved
- if signdoc:
- if i.status == "ok" and not i.signed_doc:
- continue
+ # run query
+ documents = Document.objects.filter(q_obj).select_related("personal_data", "medical_data", "document_type", "user")
- # prepare images in base64
- personal = None
- medical = None
- vac_file = ""
- health_file = ""
- sign_doc_file = ""
- if i.personal_data:
- personal = i.personal_data
- if i.medical_data:
- medical = i.medical_data
- if medical.vac_certificate.name:
- vac_file = "/server/media/" + str(i.id) + "/vac_certificate/doc"
+ users = documents.values("user__username", "user__first_name", "user__last_name")
- if medical.health_care_certificate.name:
- health_file = "/server/media/" + str(i.id) + "/health_care_certificate/doc"
-
- if i.signed_doc:
- sign_doc_file = "/server/media/" + str(i.id) + "/signed_doc/doc"
-
- doc_group = i.user.groups.values_list('name', flat=True)[0]
-
- users.append(i.user)
- out.append([i, KeyVal.objects.filter(container=i), personal,
- medical, doc_group, vac_file, health_file, sign_doc_file])
+ vac_file = ["/server/media/", "/vac_certificate/doc"]
+ health_file = ["/server/media/", "/health_care_certificate/doc"]
+ sign_doc_file = ["/server/media/", "/signed_doc/doc"]
# get types and users for chips autocompletation
auto_types = DocumentType.objects.filter(
Q(group_private=False) | Q(group__in=groups_view))
context = {
+ "vac_file": vac_file,
+ "health_file": health_file,
+ "sign_doc_file": sign_doc_file,
"types": auto_types,
"users": users,
"groups": groups_view,
- "docs": out,
+ "docs": documents,
"hidden_check": hidden_check,
"wait_check": wait_check,
"selfsign_check": selfsign_check,
@@ -1663,22 +1609,23 @@ def media_request(request, id=0, t="", flag=""): elif flag == "doc":
doc = Document.objects.get(id=id)
- doc_group = doc.user.groups.values_list('name', flat=True)[0]
+ doc_group = doc.group.name
+
+ groups = request.user.groups.values_list('name', flat=True)
+ group_view = "capi" in groups and len(GroupSettings.objects.filter(group__name=doc_group).filter(view_documents=True)) != 0
# check if user can view media
if request.user.is_staff:
# user is staff
- groups = request.user.groups.values_list('name', flat=True)
if doc_group not in groups:
return
elif request.user.has_perm("client.staff"):
# user is psudo-staff
- groups = request.user.groups.values_list('name', flat=True)[1:]
- if doc_group not in groups:
+ if doc_group not in groups[1:] and not group_view:
return
else:
# is normal user
- if doc.user != request.user:
+ if doc.user != request.user and not group_view:
return
if t == "health_care_certificate":
diff --git a/version.txt b/version.txt index 28bb89b..e25165c 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.3 -rev=11 +rev=12 |