diff options
Diffstat (limited to '')
-rw-r--r-- | client/migrations/0003_auto_20200731_1035.py | 19 | ||||
-rw-r--r-- | client/models.py | 2 | ||||
-rw-r--r-- | client/templates/client/index.html | 8 | ||||
-rw-r--r-- | client/views.py | 4 | ||||
-rw-r--r-- | server/templates/server/doc_list.html | 24 | ||||
-rw-r--r-- | server/views.py | 7 |
6 files changed, 56 insertions, 8 deletions
diff --git a/client/migrations/0003_auto_20200731_1035.py b/client/migrations/0003_auto_20200731_1035.py new file mode 100644 index 0000000..7a31dce --- /dev/null +++ b/client/migrations/0003_auto_20200731_1035.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.7 on 2020-07-31 08:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0002_auto_20200730_1951'), + ] + + operations = [ + migrations.AlterField( + model_name='document', + name='medical_data', + field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='client.MedicalData'), + ), + ] diff --git a/client/models.py b/client/models.py index 5d59e3e..dd5d998 100644 --- a/client/models.py +++ b/client/models.py @@ -69,7 +69,7 @@ class Document(models.Model): PersonalData, default=None, on_delete=models.PROTECT, null=True) medical_data = models.ForeignKey( - MedicalData, default=None, on_delete=models.PROTECT, null=True) + MedicalData, default=None, on_delete=models.SET_NULL, null=True) signed_doc = models.FileField(default=None, upload_to='documents/', null=True) diff --git a/client/templates/client/index.html b/client/templates/client/index.html index fd8316b..1915792 100644 --- a/client/templates/client/index.html +++ b/client/templates/client/index.html @@ -155,8 +155,13 @@ {% if doc.0.document_type.medical_data %} <li> <div class="collapsible-header"> - <i class="material-icons">healing</i>Dati medici + {% if doc.0.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 %} <div class="collapsible-body"><span> <div class="row"> <div class="col s12"> @@ -279,6 +284,7 @@ <label for="misc">Se sì quali</label> </div> </span></div> + {% endif %} </li> {% endif %} {% if doc.0.document_type.custom_data %} diff --git a/client/views.py b/client/views.py index 51351dd..ae5f2d5 100644 --- a/client/views.py +++ b/client/views.py @@ -81,9 +81,9 @@ def index(request): medical = None vac_file = "" health_file = "" - if i.document_type.personal_data: + if i.personal_data: personal = i.personal_data - if i.document_type.medical_data: + if i.medical_data: medical = i.medical_data if medical.vac_certificate.name: diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html index 302a1d9..7bdbb17 100644 --- a/server/templates/server/doc_list.html +++ b/server/templates/server/doc_list.html @@ -34,7 +34,7 @@ </label> </a> </li> - <li><a class="tooltipped" data-position="top" data-tooltip="Archivia selezionati" onclick="send('archive')"><i class="material-icons">archive</i></a></li> + <li><a class="tooltipped modal-trigger" href="#modal2" data-position="top" data-tooltip="Archivia selezionati"><i class="material-icons">archive</i></a></li> <li><a class="tooltipped" data-position="top" data-tooltip="Dearchivia selezionati" Onclick="send('unarchive')"><i class="material-icons">unarchive</i></a></li> {% if settings.DEBUG %} <li><a class="tooltipped" data-position="top" data-tooltip="Approva selezionati" Onclick="send('approve')"><i class="material-icons left">check</i>DEBUG</a></li> @@ -50,6 +50,20 @@ {% endblock %} {% block content %} + +<div id="modal2" class="modal"> + <div class="modal-content"> + <h4>Attenzione</h4> + <p> + Se il documento contine dati medici quando archiviato tutti i dati medici verranno eliminati. + </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('archive')" class="modal-close waves-effect waves-green btn-flat">Archivia documenti</a> + </div> +</div> + <form id="selection" action="{% url 'doclist' %}" method="post"> {% csrf_token %} <div id="modal1" class="modal"> @@ -245,8 +259,13 @@ {% if doc.0.document_type.medical_data %} <li> <div class="collapsible-header"> - <i class="material-icons">healing</i>Dati medici + {% if doc.0.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 %} <div class="collapsible-body"><span> <div class="row"> <div class="col s12"> @@ -369,6 +388,7 @@ <label for="misc">Se sì quali</label> </div> </span></div> + {% endif %} </li> {% endif %} {% if doc.0.document_type.custom_data %} diff --git a/server/views.py b/server/views.py index b3db149..b4bd06e 100644 --- a/server/views.py +++ b/server/views.py @@ -508,6 +508,9 @@ def doclist(request): elif request.POST["action"] == 'archive': if i.status == 'ok': i.status = 'archive' + if i.medical_data: + i.medical_data.delete() + i.medical_data.save() i.save() else: error = True @@ -603,9 +606,9 @@ def doclist(request): medical = None vac_file = "" health_file = "" - if i.document_type.personal_data: + if i.personal_data: personal = i.personal_data - if i.document_type.medical_data: + if i.medical_data: medical = i.medical_data if medical.vac_certificate.name: with open(medical.vac_certificate.name, 'rb') as image_file: |