aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to '')
-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
8 files changed, 278 insertions, 45 deletions
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,