aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/migrations/0010_auto_20220102_1933.py23
-rw-r--r--client/models.py2
-rw-r--r--client/templates/client/index.html730
-rw-r--r--client/views.py196
4 files changed, 480 insertions, 471 deletions
diff --git a/client/migrations/0010_auto_20220102_1933.py b/client/migrations/0010_auto_20220102_1933.py
new file mode 100644
index 0000000..45d6f08
--- /dev/null
+++ b/client/migrations/0010_auto_20220102_1933.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.1.4 on 2022-01-02 18:33
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('client', '0009_merge_20210723_1805'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='usercode',
+ name='midata_id',
+ field=models.IntegerField(default=0),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='midata_token',
+ field=models.CharField(default='', max_length=1024),
+ ),
+ ]
diff --git a/client/models.py b/client/models.py
index db31194..b94806b 100644
--- a/client/models.py
+++ b/client/models.py
@@ -113,6 +113,8 @@ class UserCode(models.Model):
school = models.CharField(default="", max_length=250)
year = models.IntegerField(default=0)
avs_number = models.CharField(default="", max_length=250)
+ midata_id = models.IntegerField(default=0)
+ midata_token = models.CharField(default="", max_length=1024)
class GroupSettings(models.Model):
group = models.ForeignKey(Group, default=None, on_delete=models.CASCADE)
diff --git a/client/templates/client/index.html b/client/templates/client/index.html
index ae3392f..e31ce34 100644
--- a/client/templates/client/index.html
+++ b/client/templates/client/index.html
@@ -16,400 +16,388 @@
<input type="hidden" name="action" id="action">
</form>
-{% if user.is_authenticated %}
- {% if user.is_staff or perms.client.approved %}
- <div id="modal_capi" class="modal">
- <div class="modal-content">
- <h4>Attenzione</h4>
- <p>I capi gruppo interessati verranno notificati dell'accesso alla pagina dei documenti.<br>
- Sei sicuro di voler continuare?
- </p>
- </div>
- <div class="modal-footer">
- <a style="color:red" href="#!" class="modal-close waves-effect waves-green btn-flat">Annulla</a>
- <a href="{% url 'doclistro' %}" class="modal-close waves-effect waves-green btn-flat">Continua</a>
- </div>
+{% if user.is_staff or perms.client.approved %}
+ <div id="modal_capi" class="modal">
+ <div class="modal-content">
+ <h4>Attenzione</h4>
+ <p>I capi gruppo interessati verranno notificati dell'accesso alla pagina dei documenti.<br>
+ Sei sicuro di voler continuare?
+ </p>
</div>
- {% if not empty %}
- <ul class="collapsible">
- {% for doc in docs %}
- <li>
- <div class="collapsible-header">
- {% if doc.status == "wait" %}
- <i class="material-icons">timelapse</i>
- {% elif doc.status == "ok" %}
- <i class="material-icons">check</i>
- {% elif doc.status == "autosign" %}
- <i class="material-icons">assignment_turned_in</i>
- {% endif %}
- {{doc.document_type.name}}
- <span class="badge" data-badge-caption="">{{doc.compilation_date}}</span>
- </div>
- <div class="collapsible-body"><span>
+ <div class="modal-footer">
+ <a style="color:red" href="#!" class="modal-close waves-effect waves-green btn-flat">Annulla</a>
+ <a href="{% url 'doclistro' %}" class="modal-close waves-effect waves-green btn-flat">Continua</a>
+ </div>
+ </div>
+ {% if not empty %}
+ <ul class="collapsible">
+ {% for doc in docs %}
+ <li>
+ <div class="collapsible-header">
{% if doc.status == "wait" %}
- <div class="hide-on-med-and-down">
- <a class="waves-effect waves-light btn {{color}}" onclick="send('f{{doc.id}}')"><i class="material-icons left">file_download</i> Scarica documento per approvazione</a>
- <a class="waves-effect waves-light btn {{color}}" onclick="send('d{{doc.id}}')"><i class="material-icons left">delete</i> Elimina iscrizione</a>
- <a class="waves-effect waves-light btn {{color}}" onclick="send('e{{doc.id}}')"><i class="material-icons left">edit</i> Modifica iscrizione</a>
- </div>
- <div style="margin-bottom: 0px;" class="hide-on-large-only row">
- <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('f{{doc.id}}')"><i class="material-icons left">file_download</i> Scarica documento per approvazione</a>
- <br>
- <br>
- <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('d{{doc.id}}')"><i class="material-icons left">delete</i> Elimina iscrizione</a>
- <br>
- <br>
- <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('e{{doc.id}}')"><i class="material-icons left">edit</i> Modifica iscrizione</a>
- </div>
+ <i class="material-icons">timelapse</i>
+ {% elif doc.status == "ok" %}
+ <i class="material-icons">check</i>
+ {% elif doc.status == "autosign" %}
+ <i class="material-icons">assignment_turned_in</i>
+ {% endif %}
+ {{doc.document_type.name}}
+ <span class="badge" data-badge-caption="">{{doc.compilation_date}}</span>
+ </div>
+ <div class="collapsible-body"><span>
+ {% if doc.status == "wait" %}
+ <div class="hide-on-med-and-down">
+ <a class="waves-effect waves-light btn {{color}}" onclick="send('f{{doc.id}}')"><i class="material-icons left">file_download</i> Scarica documento per approvazione</a>
+ <a class="waves-effect waves-light btn {{color}}" onclick="send('d{{doc.id}}')"><i class="material-icons left">delete</i> Elimina iscrizione</a>
+ <a class="waves-effect waves-light btn {{color}}" onclick="send('e{{doc.id}}')"><i class="material-icons left">edit</i> Modifica iscrizione</a>
+ </div>
+ <div style="margin-bottom: 0px;" class="hide-on-large-only row">
+ <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('f{{doc.id}}')"><i class="material-icons left">file_download</i> Scarica documento per approvazione</a>
<br>
<br>
- {% elif doc.status == "autosign" %}
- <div id="modal{{doc.id}}" class="modal">
- <div class="modal-content">
- <h4>Attenzione</h4>
- <p>Approvo il documento accettando tutte le clausole apposte su di esso. <br>
- Comprovo come veritieri e completi tutti i dati apposti sul documento.
- {% if doc.document_type.medical_data %}
- <br>
- Autorizzo i capi ad usare i dati medici, in caso d'emergenza, ed intraprendere i passi necessari per dare avvio a cure mediche d’urgenza anche senza essere ulteriormente consultato/a.
- {% endif %}
- {% if doc.document_type.custom_message %}
- <br>
- <br>
- Inoltre accetto e prendo nota della seguente clausula aggiuntiva: <br>
- {{doc.document_type.custom_message_text}}
- {% endif %}
+ <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('d{{doc.id}}')"><i class="material-icons left">delete</i> Elimina iscrizione</a>
+ <br>
+ <br>
+ <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('e{{doc.id}}')"><i class="material-icons left">edit</i> Modifica iscrizione</a>
+ </div>
+ <br>
+ <br>
+ {% elif doc.status == "autosign" %}
+ <div id="modal{{doc.id}}" class="modal">
+ <div class="modal-content">
+ <h4>Attenzione</h4>
+ <p>Approvo il documento accettando tutte le clausole apposte su di esso. <br>
+ Comprovo come veritieri e completi tutti i dati apposti sul documento.
+ {% if doc.document_type.medical_data %}
<br>
+ Autorizzo i capi ad usare i dati medici, in caso d'emergenza, ed intraprendere i passi necessari per dare avvio a cure mediche d’urgenza anche senza essere ulteriormente consultato/a.
+ {% endif %}
+ {% if doc.document_type.custom_message %}
<br>
- <b>Una volta approvata l'iscrizione non potrà più essere modificata o annullata.<br>
- Sei sicuro di volerla approvare?</b>
- </p>
- </div>
- <div class="modal-footer">
- <a style="color:red" href="#!" class="modal-close waves-effect waves-green btn-flat">Annulla</a>
- <a onclick="send('a{{doc.id}}')" class="modal-close waves-effect waves-green btn-flat">Approva</a>
- </div>
- </div>
- <div class="hide-on-med-and-down">
- <a class="waves-effect waves-light btn {{color}} modal-trigger" href="#modal{{doc.id}}"><i class="material-icons left">check</i>Approva iscrizione</a>
- <a class="waves-effect waves-light btn {{color}}" onclick="send('d{{doc.id}}')"><i class="material-icons left">delete</i>Elimina iscrizione</a>
- <a class="waves-effect waves-light btn {{color}}" onclick="send('e{{doc.id}}')"><i class="material-icons left">edit</i>Modifica iscrizione</a>
- </div>
- <div style="margin-bottom: 0px;" class="hide-on-large-only row">
- <a class="col s12 waves-effect waves-light btn {{color}} modal-trigger" href="#modal{{doc.id}}"><i class="material-icons left">check</i>Approva iscrizione</a>
- <br>
- <br>
- <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('d{{doc.id}}')"><i class="material-icons left">delete</i>Elimina iscrizione</a>
+ <br>
+ Inoltre accetto e prendo nota della seguente clausula aggiuntiva: <br>
+ {{doc.document_type.custom_message_text}}
+ {% endif %}
<br>
<br>
- <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('e{{doc.id}}')"><i class="material-icons left">edit</i>Modifica iscrizione</a>
+ <b>Una volta approvata l'iscrizione non potrà più essere modificata o annullata.<br>
+ Sei sicuro di volerla approvare?</b>
+ </p>
</div>
+ <div class="modal-footer">
+ <a style="color:red" href="#!" class="modal-close waves-effect waves-green btn-flat">Annulla</a>
+ <a onclick="send('a{{doc.id}}')" class="modal-close waves-effect waves-green btn-flat">Approva</a>
+ </div>
+ </div>
+ <div class="hide-on-med-and-down">
+ <a class="waves-effect waves-light btn {{color}} modal-trigger" href="#modal{{doc.id}}"><i class="material-icons left">check</i>Approva iscrizione</a>
+ <a class="waves-effect waves-light btn {{color}}" onclick="send('d{{doc.id}}')"><i class="material-icons left">delete</i>Elimina iscrizione</a>
+ <a class="waves-effect waves-light btn {{color}}" onclick="send('e{{doc.id}}')"><i class="material-icons left">edit</i>Modifica iscrizione</a>
+ </div>
+ <div style="margin-bottom: 0px;" class="hide-on-large-only row">
+ <a class="col s12 waves-effect waves-light btn {{color}} modal-trigger" href="#modal{{doc.id}}"><i class="material-icons left">check</i>Approva iscrizione</a>
<br>
<br>
- {% endif %}
- <ul class="collection">
- <li class="collection-item">
- <i class="material-icons left">confirmation_number</i>{{doc.code}}
- </li>
- </ul>
- <ul class="collapsible">
- {% if doc.document_type.personal_data %}
- <li>
- <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 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.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.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="{{base_group}}" id="branca" type="text">
- <label for="branca">Branca</label>
- </div>
- <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.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.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.personal_data.country}}" name="country" id="country" type="text" >
- <label for="country">Comune</label>
- </div>
- <div class="input-field col l4 s12">
- <input disabled value="{{doc.personal_data.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.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.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.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.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.personal_data.year}}" name="year" id="year" type="text" >
- <label for="year">Classe</label>
- </div>
+ <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('d{{doc.id}}')"><i class="material-icons left">delete</i>Elimina iscrizione</a>
+ <br>
+ <br>
+ <a class="col s12 waves-effect waves-light btn {{color}}" onclick="send('e{{doc.id}}')"><i class="material-icons left">edit</i>Modifica iscrizione</a>
+ </div>
+ <br>
+ <br>
+ {% endif %}
+ <ul class="collection">
+ <li class="collection-item">
+ <i class="material-icons left">confirmation_number</i>{{doc.code}}
+ </li>
+ </ul>
+ <ul class="collapsible">
+ {% if doc.document_type.personal_data %}
+ <li>
+ <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 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.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.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="{{base_group}}" id="branca" type="text">
+ <label for="branca">Branca</label>
+ </div>
+ <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.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.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.personal_data.country}}" name="country" id="country" type="text" >
+ <label for="country">Comune</label>
+ </div>
+ <div class="input-field col l4 s12">
+ <input disabled value="{{doc.personal_data.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.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.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.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.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.personal_data.year}}" name="year" id="year" type="text" >
+ <label for="year">Classe</label>
</div>
- </span></div>
- </li>
- {% endif %}
- {% if doc.document_type.medical_data %}
- <li>
- <div class="collapsible-header">
- {% 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>
+ </span></div>
+ </li>
+ {% endif %}
+ {% if doc.document_type.medical_data %}
+ <li>
+ <div class="collapsible-header">
{% if doc.medical_data %}
- <div class="collapsible-body"><span>
- <div class="row">
- <div class="col s12">
- <h6>Persona di contatto in caso di necessit&agrave;</h6>
- </div>
+ <i class="material-icons">healing</i>Dati medici
+ {% else %}
+ <i class="material-icons">healing</i><del>Dati medici</del>
+ {% endif %}
+ </div>
+ {% if doc.medical_data %}
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="col s12">
+ <h6>Persona di contatto in caso di necessit&agrave;</h6>
</div>
- <div class="row">
- <div class="input-field col l6 s12">
- <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.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.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.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.medical_data.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="input-field col l6 s12">
+ <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="row">
- <div class="col s12">
- <h6>Assicurazione</h6>
- </div>
+ <div class="input-field col l3 s12">
+ <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="row">
- <div class="input-field col l4 s12">
- <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.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.medical_data.rc}}" name="rc" id="rc" type="text" >
- <label for="rc">Responsabilit&agrave; civile</label>
- </div>
+ <div class="input-field col l3 s12">
+ <input disabled name="cell_phone" value="{{doc.medical_data.cell_phone}}" id="cellphone" type="text" >
+ <label for="cell_phone">Cellulare</label>
</div>
- <div class="row">
- <div class="switch col s12">
- &Egrave; sostenitore REGA&nbsp;&nbsp;
- <label>
- No
- <input disabled name="rega" type="checkbox" {% if doc.medical_data.rega %}checked="checked"{%endif%}>
- <span class="lever"></span>
- Si
- </label>
- </div>
+ <div class="input-field col l9 s12">
+ <input disabled value="{{doc.medical_data.address}}" name="address" id="address" type="text" >
+ <label for="address">Indirizzo completo</label>
</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.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.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.medical_data.medic_address}}" name="medic_address" id="medic_address" type="text" >
- <label for="medic_address">Indirizzo completo</label>
- </div>
+ <div class="input-field col l3 s12">
+ <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 class="row">
- <div class="col s12">
- <h6>Scheda medica personale</h6>
- </div>
- <div class="input-field col s12">
- <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.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.medical_data.tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text">
- </div>
- <div class="input-field col s12">
- <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&nbsp;&nbsp;
- <label>
- No
- <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.medical_data.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.medical_data.misc_bool %}checked="checked"{%endif%}>
- <span class="lever"></span>
- Si
- </label>
- </div>
- <div class="input-field col s12">
- <input disabled value="{{doc.medical_data.misc}}" name="misc" id="misc" type="text">
- <label for="misc">Se s&igrave; quali</label>
- </div>
- </span></div>
- {% endif %}
- </li>
- {% endif %}
- {% if doc.document_type.custom_data %}
- <li>
- <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|doc_key %}
- <tr>
- <td>{{key.key}}</td>
- <td>{{key.value}}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </span></div>
- </li>
- {% endif %}
- <li>
- <div class="collapsible-header">
- <i class="material-icons">attach_file</i>Allegati
+ <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.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.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.medical_data.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.medical_data.rega %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
</div>
- <div class="collapsible-body"><span>
- <div class="row">
- <div class="col s12">
- <div class="card">
- <div class="card-image">
- {% if doc.signed_doc %} <img class="lazyload" data-src="{{ sign_doc_file.0 }}{{ doc.id }}{{ sign_doc_file.1 }}"> {% endif %}
- </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.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.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.medical_data.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.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.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.medical_data.tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text">
+ </div>
+ <div class="input-field col s12">
+ <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&nbsp;&nbsp;
+ <label>
+ No
+ <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.medical_data.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.medical_data.misc_bool %}checked="checked"{%endif%}>
+ <span class="lever"></span>
+ Si
+ </label>
+ </div>
+ <div class="input-field col s12">
+ <input disabled value="{{doc.medical_data.misc}}" name="misc" id="misc" type="text">
+ <label for="misc">Se s&igrave; quali</label>
+ </div>
+ </span></div>
+ {% endif %}
+ </li>
+ {% endif %}
+ {% if doc.document_type.custom_data %}
+ <li>
+ <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|doc_key %}
+ <tr>
+ <td>{{key.key}}</td>
+ <td>{{key.value}}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </span></div>
+ </li>
+ {% endif %}
+ <li>
+ <div class="collapsible-header">
+ <i class="material-icons">attach_file</i>Allegati
+ </div>
+ <div class="collapsible-body"><span>
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ {% if doc.signed_doc %} <img class="lazyload" data-src="{{ sign_doc_file.0 }}{{ doc.id }}{{ sign_doc_file.1 }}"> {% endif %}
</div>
</div>
</div>
- {% if doc.medical_data %}
- <div class="row">
- <div class="col s12">
- <div class="card">
- <div class="card-image">
- {% if doc.medical_data.health_care_certificate %}<img class="lazyload" data-src="{{ health_file.0 }}{{ doc.id }}{{ health_file.1}}">{% endif %}
- </div>
+ </div>
+ {% if doc.medical_data %}
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ {% if doc.medical_data.health_care_certificate %}<img class="lazyload" data-src="{{ health_file.0 }}{{ doc.id }}{{ health_file.1}}">{% endif %}
</div>
</div>
</div>
- <div class="row">
- <div class="col s12">
- <div class="card">
- <div class="card-image">
- {% if doc.medical_data.vac_certificate %}<img class="lazyload" data-src="{{ vac_file.0 }}{{ doc.id }}{{ vac_file.1}}">{% endif %}
- </div>
+ </div>
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="card-image">
+ {% if doc.medical_data.vac_certificate %}<img class="lazyload" data-src="{{ vac_file.0 }}{{ doc.id }}{{ vac_file.1}}">{% endif %}
</div>
</div>
</div>
- {% endif %}
- </span></div>
- </li>
- </ul>
- </span></div>
- </li>
- {% endfor %}
- </ul>
- {% endif %}
- <div class="fixed-action-btn">
- <a id="add" class="btn-floating btn-large {{color}}" href="{% url 'create'%}">
- <i class="large material-icons">add</i>
- </a>
- </div>
- {% else %}
- <div class="row">
- <div class="col l4 offset-l4 m8 offset-m2 s12">
- <div class="card">
- <div class="card-content">
- <p>Il tuo utente non &egrave; ancora stato approvato.</p>
- <br>
- {% if user_code %}
- <p>Per approvare l'utente invia il seguente codice al capo branca:</p>
- <h3 class="center-align">{{user_code}}<h3>
- {% else %}
- <p class="hide-on-small-only">Per approvare l'utente inserire prima i propri dati personali e medici cliccando il proprio nome in alto a destra. Torna in seguito su questa pagina per i prossimi passaggi.</p>
- <p class="hide-on-med-and-up">Per approvare l'utente inserire prima i propri dati personali e medici cliccando l'icona <i class="material-icons tiny">person</i> in alto. Torna in seguito su questa pagina per i prossimi passaggi.</p>
- {% endif %}
- </div>
- </div>
- </div>
- </div>
+ </div>
+ {% endif %}
+ </span></div>
+ </li>
+ </ul>
+ </span></div>
+ </li>
+ {% endfor %}
+ </ul>
{% endif %}
+ <div class="fixed-action-btn">
+ <a id="add" class="btn-floating btn-large {{color}}" href="{% url 'create'%}">
+ <i class="large material-icons">add</i>
+ </a>
+ </div>
{% else %}
<div class="row">
<div class="col l4 offset-l4 m8 offset-m2 s12">
<div class="card">
<div class="card-content">
- <p>Se hai gi&agrave; un account clicca login in alto a destra. Altrimenti clicca registrazione</p>
+ <p>Il tuo utente non &egrave; ancora stato approvato.</p>
+ <br>
+ {% if user_code %}
+ <p>Per approvare l'utente invia il seguente codice al capo branca:</p>
+ <h3 class="center-align">{{user_code}}<h3>
+ {% else %}
+ <p class="hide-on-small-only">Per approvare l'utente inserire prima i propri dati personali e medici cliccando il proprio nome in alto a destra. Torna in seguito su questa pagina per i prossimi passaggi.</p>
+ <p class="hide-on-med-and-up">Per approvare l'utente inserire prima i propri dati personali e medici cliccando l'icona <i class="material-icons tiny">person</i> in alto. Torna in seguito su questa pagina per i prossimi passaggi.</p>
+ {% endif %}
</div>
</div>
</div>
@@ -419,7 +407,6 @@
{% block script %}
$(document).ready(function(){
- {% if user.is_authenticated %}
{% if user.is_staff or perms.client.approved %}
$('.collapsible').collapsible();
$('.tap-target').tapTarget();
@@ -428,22 +415,19 @@ $(document).ready(function(){
$('.tap-target').tapTarget('open');
{% endif %}
{% endif %}
- {% endif %}
lazyload();
});
-{% if user.is_authenticated %}
- {% if user.is_staff or perms.client.approved %}
- $('*').click(function(event) {
- if (this === event.target) {
- $('.tap-target').tapTarget('close');
- }
- });
- function send(id) {
- var form = document.getElementById('form')
- var action = document.getElementById('action')
- action.setAttribute('value', id);
- form.submit()
- }
- {% endif %}
+{% if user.is_staff or perms.client.approved %}
+ $('*').click(function(event) {
+ if (this === event.target) {
+ $('.tap-target').tapTarget('close');
+ }
+ });
+ function send(id) {
+ var form = document.getElementById('form')
+ var action = document.getElementById('action')
+ action.setAttribute('value', id);
+ form.submit()
+ }
{% endif %}
{% endblock %}
diff --git a/client/views.py b/client/views.py
index bc0b071..41bb3dd 100644
--- a/client/views.py
+++ b/client/views.py
@@ -12,109 +12,109 @@ from datetime import datetime
import pytz
from random import randint
+@login_required()
def index(request):
context = {}
group_view = False
- # check if user is logged
- if (request.user.is_authenticated):
- if not (request.user.is_staff or request.user.has_perm("client.approved")):
- # generate code if user has no code
- users = UserCode.objects.filter(user=request.user)
- code = None
- if (len(users) == 0):
- while (True):
- code = randint(100000, 999999)
- if len(UserCode.objects.filter(code=code)) == 0:
- break
- medic = MedicalData()
- medic.save()
- userCode = UserCode(user=request.user, code=code, medic=medic)
- userCode.save()
-
- user_code = None
- usercode = UserCode.objects.filter(user=request.user)[0]
- if request.user.first_name != "" and request.user.last_name != "" and request.user.email != "" and usercode.phone != "":
- user_code = "U" + str(usercode.code)
- context = {"user_code": user_code}
- else:
- # get user group
- groups = request.user.groups.all()
-
- # check if any group has enabled RO documents
- if request.user.is_staff or len(groups.filter(name="capi")) == 0:
- # if user is staff then not needed
- gr = []
- elif request.user.has_perm("client.staff"):
- gr = GroupSettings.objects.filter(group__in=groups).filter(view_documents=True).filter(~Q(group=groups[0]))
- else:
- gr = GroupSettings.objects.filter(group__in=groups).filter(view_documents=True)
-
- group_view = len(gr) != 0
-
- # user action
- if request.method == "POST":
- # get document id
- document = Document.objects.get(id=request.POST["action"][1:])
-
- # check if document is valid to modify
- if document.user != request.user:
- return
-
- if document.status == "ok" or document.status == "archive":
- return
-
- # execute action
- if request.POST["action"][0] == 'f':
- # generate approve pdf
- template = get_template('client/approve_doc_pdf.html')
- context = {'doc': document}
- html = template.render(context)
- pdf = pdfkit.from_string(html, False)
- result = BytesIO(pdf)
- result.seek(0)
- return FileResponse(result, filename=document.document_type.name+".pdf")
- elif request.POST["action"][0] == 'a':
- # sign autosign doc
- if document.status == "autosign":
- document.status = "ok"
- document.save()
- return HttpResponseRedirect("/")
- elif request.POST["action"][0] == 'd':
- # delete doc
- document.delete()
- return HttpResponseRedirect("/")
- elif request.POST["action"][0] == 'e':
- # edit doc generate context and render edit page
- document_type = document.document_type
- context = {
- 'doctype': document_type,
- }
- context['doc'] = document
- context['personal_data'] = document_type.personal_data
- context['medical_data'] = document_type.medical_data
- context['custom_data'] = document_type.custom_data
- context['keys'] = KeyVal.objects.filter(container=document)
- context['custom_message'] = document_type.custom_message
- context['custom_message_text'] = document_type.custom_message_text
- return edit_wrapper(request, context)
-
- # show only docs of the user and non archived
- documents = Document.objects.filter(
- Q(user=request.user) & ~Q(status='archive')).select_related("personal_data", "medical_data", "document_type", "user")
-
- vac_file = ["/server/media/", "/vac_certificate/doc"]
- health_file = ["/server/media/", "/health_care_certificate/doc"]
- sign_doc_file = ["/server/media/", "/signed_doc/doc"]
-
+ if not (request.user.is_staff or request.user.has_perm("client.approved")):
+ # generate code if user has no code
+ users = UserCode.objects.filter(user=request.user)
+ code = None
+ if (len(users) == 0):
+ while (True):
+ code = randint(100000, 999999)
+ if len(UserCode.objects.filter(code=code)) == 0:
+ break
+ medic = MedicalData()
+ medic.save()
+ userCode = UserCode(user=request.user, code=code, medic=medic)
+ userCode.save()
+
+ user_code = None
+ usercode = UserCode.objects.filter(user=request.user)[0]
+ if request.user.first_name != "" and request.user.last_name != "" and request.user.email != "" and usercode.phone != "":
+ user_code = "U" + str(usercode.code)
+ context = {"user_code": user_code}
+ return render(request, 'client/index.html', context)
+
+ # get user group
+ groups = request.user.groups.all()
+
+ # check if any group has enabled RO documents
+ if request.user.is_staff or len(groups.filter(name="capi")) == 0:
+ # if user is staff then not needed
+ gr = []
+ elif request.user.has_perm("client.staff"):
+ gr = GroupSettings.objects.filter(group__in=groups).filter(view_documents=True).filter(~Q(group=groups[0]))
+ else:
+ gr = GroupSettings.objects.filter(group__in=groups).filter(view_documents=True)
+
+ group_view = len(gr) != 0
+
+ # user action
+ if request.method == "POST":
+ # get document id
+ document = Document.objects.get(id=request.POST["action"][1:])
+
+ # check if document is valid to modify
+ if document.user != request.user:
+ return
+
+ if document.status == "ok" or document.status == "archive":
+ return
+
+ # execute action
+ if request.POST["action"][0] == 'f':
+ # generate approve pdf
+ template = get_template('client/approve_doc_pdf.html')
+ context = {'doc': document}
+ html = template.render(context)
+ pdf = pdfkit.from_string(html, False)
+ result = BytesIO(pdf)
+ result.seek(0)
+ return FileResponse(result, filename=document.document_type.name+".pdf")
+ elif request.POST["action"][0] == 'a':
+ # sign autosign doc
+ if document.status == "autosign":
+ document.status = "ok"
+ document.save()
+ return HttpResponseRedirect("/")
+ elif request.POST["action"][0] == 'd':
+ # delete doc
+ document.delete()
+ return HttpResponseRedirect("/")
+ elif request.POST["action"][0] == 'e':
+ # edit doc generate context and render edit page
+ document_type = document.document_type
context = {
- "docs": documents,
- "base_group": groups[0].name,
- "empty": len(documents) == 0,
- "group_view": group_view,
- "vac_file": vac_file,
- "health_file": health_file,
- "sign_doc_file": sign_doc_file
+ 'doctype': document_type,
}
+ context['doc'] = document
+ context['personal_data'] = document_type.personal_data
+ context['medical_data'] = document_type.medical_data
+ context['custom_data'] = document_type.custom_data
+ context['keys'] = KeyVal.objects.filter(container=document)
+ context['custom_message'] = document_type.custom_message
+ context['custom_message_text'] = document_type.custom_message_text
+ return edit_wrapper(request, context)
+
+ # show only docs of the user and non archived
+ documents = Document.objects.filter(
+ Q(user=request.user) & ~Q(status='archive')).select_related("personal_data", "medical_data", "document_type", "user")
+
+ vac_file = ["/server/media/", "/vac_certificate/doc"]
+ health_file = ["/server/media/", "/health_care_certificate/doc"]
+ sign_doc_file = ["/server/media/", "/signed_doc/doc"]
+
+ context = {
+ "docs": documents,
+ "base_group": groups[0].name,
+ "empty": len(documents) == 0,
+ "group_view": group_view,
+ "vac_file": vac_file,
+ "health_file": health_file,
+ "sign_doc_file": sign_doc_file
+ }
return render(request, 'client/index.html', context)