diff options
Diffstat (limited to '')
22 files changed, 951 insertions, 120 deletions
diff --git a/accounts/templates/accounts/index.html b/accounts/templates/accounts/index.html index 5ba2dc1..b3f25f0 100644 --- a/accounts/templates/accounts/index.html +++ b/accounts/templates/accounts/index.html @@ -55,16 +55,16 @@ <div class="col l8 offset-l2 s12"> <div class="card-panel"> <div class="row"> - <form action="{% url 'personal'%}" method="post" id="personal_form" class="col s12"> + <form action="{% url 'personal'%}" method="post" id="form" class="col s12"> {% csrf_token %} <div class="row"> <div class="input-field col s4"> - <input name="first_name" value="{{first_name}}" id="first_name" type="text" class="validate"> - <label for="first_name">First Name</label> + <input name="first_name" value="{{first_name}}" id="first_name" type="text" > + <label for="first_name">Nome</label> </div> <div class="input-field col s4"> - <input name="last_name" value="{{last_name}}" id="last_name" type="text" class="validate"> - <label for="last_name">Last Name</label> + <input name="last_name" value="{{last_name}}" id="last_name" type="text" > + <label for="last_name">Cognome</label> </div> <div class="input-field col s4"> <input name="birth_date" value="{{birth_date}}" id="birth_date" type="text" class="datepicker"> @@ -84,72 +84,242 @@ <label>Branca</label> </div> <div class="input-field col s8"> - <input value="{{parent_name}}" name="parent_name" id="parent_name" type="text" class="validate"> + <input value="{{parent_name}}" name="parent_name" id="parent_name" type="text" > <label for="parent_name">Nome dei genitori</label> </div> </div> <div class="row"> <div class="input-field col s12"> - <input value="{{via}}" name="via" id="via" type="text" class="validate"> + <input value="{{via}}" name="via" id="via" type="text" > <label for="via">Via e numero</label> </div> </div> <div class="row"> <div class="input-field col s4"> - <input value="{{cap}}" name="cap" id="cap" type="text" class="validate"> + <input value="{{cap}}" name="cap" id="cap" type="text" > <label for="cap">CAP</label> </div> <div class="input-field col s4"> - <input value="{{country}}" name="country" id="country" type="text" class="validate"> + <input value="{{country}}" name="country" id="country" type="text" > <label for="country">Paese</label> </div> <div class="input-field col s4"> - <input value="{{nationality}}" name="nationality" id="nationality" type="text" class="validate"> - <label for="nationality">Nazionalita`</label> + <input value="{{nationality}}" name="nationality" id="nationality" type="text" > + <label for="nationality">Nazionalità</label> </div> </div> <div class="row"> <div class="input-field col s4"> - <input value="{{phone}}" name="phone" id="phone" type="text" class="validate"> + <input value="{{phone}}" name="phone" id="phone" type="text" > <label for="phone">Cellulare</label> </div> <div class="input-field col s4"> - <input value="{{home_phone}}" name="home_phone" id="home_phone" type="text" class="validate"> + <input value="{{home_phone}}" name="home_phone" id="home_phone" type="text" > <label for="home_phone">Telefono di casa</label> </div> <div class="input-field col s4"> - <input value="{{email}}" name="email" id="email" type="text" class="validate"> + <input value="{{email}}" name="email" id="email" type="text" > <label for="email">Email</label> </div> </div> <div class="row"> <div class="input-field col s8"> - <input value="{{school}}" name="school" id="school" type="text" class="validate"> + <input value="{{school}}" name="school" id="school" type="text" > <label for="school">Scuola frequentata</label> </div> <div class="input-field col s4"> - <input value="{{year}}" name="year" id="year" type="text" class="validate"> + <input value="{{year}}" name="year" id="year" type="text" > <label for="year">Classe</label> </div> </div> <div class="fixed-action-btn"> - <a class="btn-floating btn-large red lighten-1" onclick="document.getElementById('personal_form').submit()"> + <a class="btn-floating btn-large red lighten-1" onclick="document.getElementById('form').submit()"> <i class="large material-icons">save</i> </a> </div> + </div> + </div> + </div> +</div> +<div id="medic" class="row"> + <div class="col l8 offset-l2 s12"> + <div class="card-panel"> + <div class="row"> + {% csrf_token %} + <div class="row"> + <div class="col s12"> + <h6>Persona di contatto in caso di necessità</h6> + </div> + </div> + <div class="row"> + <div class="input-field col s6"> + <input name="emer_name" value="{{emer_name}}" id="emer_name" type="text" > + <label for="emer_name">Nome e cognome</label> + </div> + <div class="input-field col s3"> + <input name="emer_relative" value="{{emer_relative}}" id="emer_relative" type="text" > + <label for="emer_releative">Parentela</label> + </div> + <div class="input-field col s3"> + <input name="cell_phone" value="{{cell_phone}}" id="cellphone" type="text" > + <label for="cell_phone">Cellulare</label> + </div> + </div> + <div class="row"> + <div class="input-field col s9"> + <input value="{{address}}" name="address" id="address" type="text" > + <label for="address">Indirizzo completo</label> + </div> + <div class="input-field col s3"> + <input value="{{emer_phone}}" name="emer_phone" id="emer_phone" type="text" > + <label for="emer_phone">Telefono di casa</label> + </div> + </div> + <div class="row"> + <div class="col s12"> + <h6>Assicurazione</h6> + </div> + </div> + <div class="row"> + <div class="input-field col s4"> + <input value="{{health_care}}" name="health_care" id="health_care" type="text" > + <label for="health_care">Cassa Malati</label> + </div> + <div class="input-field col s4"> + <input value="{{injuries}}" name="injuries" id="injuries" type="text" > + <label for="injuries">Infortuni</label> + </div> + <div class="input-field col s4"> + <input value="{{rc}}" name="rc" id="rc" type="text" > + <label for="rc">Responsabilità civile</label> + </div> + </div> + <div class="row"> + <div class="switch col s12"> + È sostenitore REGA + <label> + No + <input name="rega" type="checkbox" {{rega_check}}> + <span class="lever"></span> + Si + </label> + </div> + </div> + <div class="row"> + <div class="col s12"> + <h6>Medico di famiglia</h6> + </div> + </div> + <div class="row"> + <div class="input-field col s6"> + <input value="{{medic_name}}" name="medic_name" id="medic_name" type="text" > + <label for="medic_name">Nome e cognome</label> + </div> + <div class="input-field col s6"> + <input value="{{medic_phone}}" name="medic_phone" id="medic_phone" type="text" > + <label for="medic_phone">Telefono studio</label> + </div> + </div> + <div class="row"> + <div class="input-field col s12"> + <input value="{{medic_address}}" name="medic_address" id="medic_address" type="text" > + <label for="medic_address">Indirizzo completo</label> + </div> + </div> + <div class="row"> + <div class="col s12"> + <h6>Scheda medica personale</h6> + </div> + </div> + <div class="row"> + <div class="input-field col s12"> + <input value="{{sickness}}" name="sickness" id="sickness" type="text" data-length="250"> + <label for="sickness">Principali malattie avute</label> + </div> + </div> + <div class="row"> + <div class="input-field col s8"> + <input value="{{vaccine}}" name="vaccine" id="vaccine" type="text" data-length="250"> + <label for="vaccine">Vacinazioni fatte</label> + </div> + <div class="input-field col s4"> + <label for="tetanus_date">Ultima vacinazione contro il tetano</label> + <input value="{{tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text" class="datepicker"> + </div> + </div> + <div class="row"> + <div class="input-field col s12"> + <input value="{{allergy}}" name="allergy" id="allergy" type="text" data-length="250"> + <label for="allergy">Allergie particolari/Intolleraze alimentari</label> + </div> + </div> + <div class="row"> + <div class="switch col s12"> + Deve assumere regolarmente medicamenti + <label> + No + <input name="drugs_bool" type="checkbox" {{drugs_check}}> + <span class="lever"></span> + Si + </label> + </div> + </div> + <div class="row"> + <div class="col s12"> + <a style="pointer-events: none; cursor: default;" class="btn red lighten-1"> + In caso dovesse assumere farmaci, avvisare comunque i capi + </a> + </div> + <div class="input-field col s12"> + <input value="{{drugs}}" name="drugs" id="drugs" type="text" data-length="250"> + <label for="drugs">Se sì quali, in che dosi e prescrizioni</label> + </div> + </div> + <div class="row"> + <div class="switch col s12"> + Informazioni particolari sullo stato di salute: (postumi di operazioni, incidenti, malattie, disturbi fisici) + <label> + No + <input name="misc_bool" type="checkbox" {{misc_check}}> + <span class="lever"></span> + Si + </label> + </div> + <div class="input-field col s12"> + <input value="{{misc}}" name="misc" id="misc" type="text" data-length="250"> + <label for="misc">Se sì quali</label> + </div> + </div> + <div class="row"> + <div class="col s12"> + <h6>Allegati</h6> + </div> + </div> + <div class="row"> + <div class="col s6"> + Certificato delle vacinazioni + </div> + <div class="col s6"> + Tessera della cassa malati + </div> + </div> + <div class="fixed-action-btn"> + <a class="btn-floating btn-large red lighten-1" onclick="document.getElementById('form').submit()"> + <i class="large material-icons">save</i> + </a> + </div> </form> </div> </div> </div> </div> -<div id="medic" class="col s12">Tabella medica</div> {% endblock %} {% block script %} var elem = $('.tabs') var options = { yearRange:100, - format:'dd.mm.yyyy', + format:'dd mmmm yyyy', i18n: { months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ], monthsShort: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic' ], @@ -176,4 +346,7 @@ var elems = document.querySelectorAll('select'); var instances = M.FormSelect.init(elems, options); }); + $(document).ready(function() { + $('input#sickness, input#vaccine, input#allergy, input#drugs, input#misc').characterCounter(); + }); {% endblock %}
\ No newline at end of file diff --git a/accounts/views.py b/accounts/views.py index 0723482..36f59cd 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -19,6 +19,7 @@ def personal(request): context = {} if request.user.is_authenticated: usercode = UserCode.objects.filter(user=request.user)[0] + medic = usercode.medic debug = "" branca_default = "" branca_castorini = "" @@ -44,6 +45,28 @@ def personal(request): usercode.year = request.POST["year"] usercode.save() + medic.emer_name = request.POST["emer_name"] + medic.emer_relative = request.POST["emer_relative"] + medic.cell_phone = request.POST["cell_phone"] + medic.address = request.POST["address"] + medic.emer_phone = request.POST["emer_phone"] + medic.health_care = request.POST["health_care"] + medic.injuries = request.POST["injuries"] + medic.rc = request.POST["rc"] + medic.rega = "rega" in request.POST + medic.medic_name = request.POST["medic_name"] + medic.medic_phone = request.POST["medic_phone"] + medic.medic_address = request.POST["medic_address"] + medic.sickness = request.POST["sickness"] + medic.vaccine = request.POST["vaccine"] + medic.tetanus_date = dateparser.parse(request.POST["tetanus_date"]) + medic.allergy = request.POST["allergy"] + medic.drugs_bool = "drugs_bool" in request.POST + medic.drugs = request.POST["drugs"] + medic.misc_bool = "misc_bool" in request.POST + medic.misc = request.POST["misc"] + medic.save() + if request.POST["branca"] != "": request.user.groups.clear() request.user.groups.add( @@ -61,6 +84,16 @@ def personal(request): else: branca_default = "selected" + rega = "" + if medic.rega: + rega = "checked='checked'" + drugs = "" + if medic.drugs_bool: + drugs = "checked='checked'" + misc = "" + if medic.misc_bool: + misc = "checked='checked'" + context = { 'first_name': request.user.first_name, 'last_name': request.user.last_name, @@ -81,6 +114,26 @@ def personal(request): 'branca_esploratori': branca_esploratori, 'branca_pionieri': branca_pionieri, 'branca_rover': branca_rover, + 'emer_name': medic.emer_name, + 'emer_relative': medic.emer_relative, + 'cell_phone': medic.cell_phone, + 'address': medic.address, + 'emer_phone': medic.emer_phone, + 'health_care': medic.health_care, + 'injuries': medic.injuries, + 'rc': medic.rc, + 'rega_check': rega, + 'medic_name': medic.medic_name, + 'medic_phone': medic.medic_phone, + 'medic_address': medic.medic_address, + 'sickness': medic.sickness, + 'vaccine': medic.vaccine, + 'tetanus_date': medic.tetanus_date, + 'allergy': medic.allergy, + 'drugs_check': drugs, + 'drugs': medic.drugs, + 'misc_check': misc, + 'misc': medic.misc, } return render(request, 'accounts/index.html', context) diff --git a/client/migrations/0015_personaldata_email.py b/client/migrations/0015_personaldata_email.py new file mode 100644 index 0000000..86f7213 --- /dev/null +++ b/client/migrations/0015_personaldata_email.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-06-20 15:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0014_auto_20200620_1506'), + ] + + operations = [ + migrations.AddField( + model_name='personaldata', + name='email', + field=models.CharField(default='', max_length=250), + ), + ] diff --git a/client/migrations/0016_auto_20200620_1733.py b/client/migrations/0016_auto_20200620_1733.py new file mode 100644 index 0000000..11fb49f --- /dev/null +++ b/client/migrations/0016_auto_20200620_1733.py @@ -0,0 +1,26 @@ +# Generated by Django 3.0.7 on 2020-06-20 15:33 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0015_personaldata_email'), + ] + + operations = [ + migrations.CreateModel( + name='MedicalData', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('medic_name', models.CharField(default='', max_length=250)), + ], + ), + migrations.AddField( + model_name='document', + name='medical_data', + field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='client.MedicalData'), + ), + ] diff --git a/client/migrations/0017_usercode_medic.py b/client/migrations/0017_usercode_medic.py new file mode 100644 index 0000000..1c4071a --- /dev/null +++ b/client/migrations/0017_usercode_medic.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.7 on 2020-06-20 18:04 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0016_auto_20200620_1733'), + ] + + operations = [ + migrations.AddField( + model_name='usercode', + name='medic', + field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.PROTECT, to='client.MedicalData'), + ), + ] diff --git a/client/migrations/0018_auto_20200620_2007.py b/client/migrations/0018_auto_20200620_2007.py new file mode 100644 index 0000000..17f40b3 --- /dev/null +++ b/client/migrations/0018_auto_20200620_2007.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-06-20 18:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0017_usercode_medic'), + ] + + operations = [ + migrations.AlterField( + model_name='medicaldata', + name='medic_name', + field=models.CharField(default='', max_length=250, null=True), + ), + ] diff --git a/client/migrations/0019_auto_20200620_2008.py b/client/migrations/0019_auto_20200620_2008.py new file mode 100644 index 0000000..15dff2f --- /dev/null +++ b/client/migrations/0019_auto_20200620_2008.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-06-20 18:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0018_auto_20200620_2007'), + ] + + operations = [ + migrations.AlterField( + model_name='medicaldata', + name='medic_name', + field=models.CharField(default='', max_length=250), + ), + ] diff --git a/client/migrations/0020_auto_20200620_2200.py b/client/migrations/0020_auto_20200620_2200.py new file mode 100644 index 0000000..cdf9cc9 --- /dev/null +++ b/client/migrations/0020_auto_20200620_2200.py @@ -0,0 +1,109 @@ +# Generated by Django 3.0.7 on 2020-06-20 20:00 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0019_auto_20200620_2008'), + ] + + operations = [ + migrations.AddField( + model_name='medicaldata', + name='address', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='allergy', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='cell_phone', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='drugs', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='drugs_bool', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='medicaldata', + name='emer_name', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='emer_phone', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='emer_relative', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='health_care', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='injuries', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='medic_address', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='medic_phone', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='misc', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='misc_bool', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='medicaldata', + name='rc', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='rega', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='medicaldata', + name='sickness', + field=models.CharField(default='', max_length=250), + ), + migrations.AddField( + model_name='medicaldata', + name='tetanus_date', + field=models.DateField(default=datetime.datetime(1970, 1, 1, 1, 0), null=True), + ), + migrations.AddField( + model_name='medicaldata', + name='vaccine', + field=models.CharField(default='', max_length=250), + ), + ] diff --git a/client/migrations/0021_documenttype_sign_req.py b/client/migrations/0021_documenttype_sign_req.py new file mode 100644 index 0000000..5538a2f --- /dev/null +++ b/client/migrations/0021_documenttype_sign_req.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-06-20 21:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0020_auto_20200620_2200'), + ] + + operations = [ + migrations.AddField( + model_name='documenttype', + name='sign_req', + field=models.BooleanField(default=False), + ), + ] diff --git a/client/migrations/0022_auto_20200620_2316.py b/client/migrations/0022_auto_20200620_2316.py new file mode 100644 index 0000000..37a602b --- /dev/null +++ b/client/migrations/0022_auto_20200620_2316.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-06-20 21:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('client', '0021_documenttype_sign_req'), + ] + + operations = [ + migrations.RenameField( + model_name='documenttype', + old_name='sign_req', + new_name='auto_sign', + ), + ] diff --git a/client/models.py b/client/models.py index e7142ac..78b8df4 100644 --- a/client/models.py +++ b/client/models.py @@ -7,6 +7,7 @@ from datetime import datetime class DocumentType(models.Model): enabled = models.BooleanField(default=False) + auto_sign = models.BooleanField(default=False) group_private = models.BooleanField(default=False) group = models.ForeignKey(Group, default=None, on_delete=models.CASCADE) personal_data = models.BooleanField(default=False) @@ -26,6 +27,30 @@ class PersonalData(models.Model): born_date = models.DateField(null=True, default=datetime.fromtimestamp(0)) home_phone = models.CharField(default="", max_length=250) phone = models.CharField(default="", max_length=250) + email = models.CharField(default="", max_length=250) + + +class MedicalData(models.Model): + emer_name = models.CharField(default="", max_length=250) + emer_relative = models.CharField(default="", max_length=250) + cell_phone = models.CharField(default="", max_length=250) + address = models.CharField(default="", max_length=250) + emer_phone = models.CharField(default="", max_length=250) + health_care = models.CharField(default="", max_length=250) + injuries = models.CharField(default="", max_length=250) + rc = models.CharField(default="", max_length=250) + rega = models.BooleanField(default=False) + medic_name = models.CharField(default="", max_length=250) + medic_phone = models.CharField(default="", max_length=250) + medic_address = models.CharField(default="", max_length=250) + sickness = models.CharField(default="", max_length=250) + vaccine = models.CharField(default="", max_length=250) + tetanus_date = models.DateField(null=True, default=datetime.fromtimestamp(0)) + allergy = models.CharField(default="", max_length=250) + drugs_bool = models.BooleanField(default=False) + drugs = models.CharField(default="", max_length=250) + misc_bool = models.BooleanField(default=False) + misc = models.CharField(default="", max_length=250) class Document(models.Model): @@ -40,6 +65,9 @@ class Document(models.Model): personal_data = models.ForeignKey( PersonalData, default=None, on_delete=models.PROTECT, null=True) + medical_data = models.ForeignKey( + MedicalData, default=None, on_delete=models.PROTECT, null=True) + class Meta: permissions = [ ("approved", "The user is approved") @@ -61,6 +89,7 @@ class Keys(models.Model): class UserCode(models.Model): user = models.ForeignKey(User, default=None, on_delete=models.CASCADE) + medic = models.ForeignKey(MedicalData, default=None, on_delete=models.PROTECT) code = models.IntegerField(default=0) parent_name = models.CharField(default="", max_length=250) via = models.CharField(default="", max_length=250) diff --git a/client/templates/client/doc_create.html b/client/templates/client/doc_create.html index 550eb54..39deb2d 100644 --- a/client/templates/client/doc_create.html +++ b/client/templates/client/doc_create.html @@ -1,6 +1,6 @@ {% extends 'registration/base.html' %} -{% block title %}Admin - Modifica Tipo{% endblock %} +{% block title %}Crea Documento{% endblock %} {% block nav %} <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a> @@ -46,14 +46,14 @@ {% 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á le informazioni personali, prego verificare che siano corrette e aggiornate</a> + <a style="pointer-events: none; cursor: default;" class="btn red lighten-1"> Il documento conterrà le informazioni personali, prego verificare che siano corrette e aggiornate</a> </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á le informazioni mediche, prego verificare che siano corrette e aggiornate</a> + <a style="pointer-events: none; cursor: default;" class="btn red lighten-1"> Il documento conterrà le informazioni mediche, prego verificare che siano corrette e aggiornate</a> </div> </div> {% endif %} @@ -68,7 +68,7 @@ {% for key in keys %} <div class="row"> <div class="input-field col s12"> - <input value="{{key.1}}" name="{{key.0.id}}" id="{{key.0.id}}" type="text" class="validate"> + <input value="{{key.1}}" name="{{key.0.id}}" id="{{key.0.id}}" type="text"> <label for="{{key.0.id}}">{{key.0.key}}</label> </div> </div> diff --git a/client/templates/client/doc_edit.html b/client/templates/client/doc_edit.html new file mode 100644 index 0000000..8cd5a98 --- /dev/null +++ b/client/templates/client/doc_edit.html @@ -0,0 +1,86 @@ +{% extends 'registration/base.html' %} + +{% block title %}Modifica documento{% endblock %} + +{% block nav %} + <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a> + <a href="#!" class="breadcrumb hide-on-med-and-down">Modifica Documento</a> +{% endblock %} + +{% block content %} +<div class="row"> + <div class="col l8 offset-l2 s12"> + <div class="card-panel"> + <div class="row"> + <form id="form" action="{% url 'edit'%}" method="post" class="col s12"> + {% csrf_token %} + <input type="hidden" name="doc" value="{{doc.id}}"> + <div class="row"> + <div class="input-field col s12"> + <select> + <option disabled selected>{{doc.document_type.name}}</option> + </select> + <label>Documento</label> + </div> + </div> + {% 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à le informazioni personali, prego verificare che siano corrette e aggiornate</a> + </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à le informazioni mediche, prego verificare che siano corrette e aggiornate</a> + </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> + </div> + {% endif %} + {% if custom_data %} + {% for key in keys %} + <div class="row"> + <div class="input-field col s12"> + <input value="{{key.1}}" name="{{key.0.id}}" id="{{key.0.id}}" type="text"> + <label for="{{key.0.id}}">{{key.0.key}}</label> + </div> + </div> + {% endfor %} + {% endif %} + <div class="row"> + <div class="col s12"> + <br> + <a class="btn waves-effect waves-light" onclick="window.history.back();" > + <i class="material-icons left">navigate_before</i>Indietro + </a> + <a class="btn waves-effect waves-light" onclick="send('save')" >Salva + <i class="material-icons right">save</i> + </a> + </div> + </div> + </form> + </div> + </div> + </div> +</div> +{% endblock %} + +{% block script %} +$(document).ready(function(){ + $('select').formSelect(); + {% if error %} + M.toast({html: '{{ error_text}}', classes: 'orange'}) + {% endif %} + }); +function send(id) { + var form = document.getElementById('form') + form.submit() +} +{% endblock %}
\ No newline at end of file diff --git a/client/templates/client/index.html b/client/templates/client/index.html index 96179b2..733f62f 100644 --- a/client/templates/client/index.html +++ b/client/templates/client/index.html @@ -13,6 +13,12 @@ <p>Usa questo bottone per creare un nuovo documento</p> </div> </div> + +<form id="form" method="post" action="{% url 'index'%}"> + {% csrf_token %} + <input type="hidden" name="action" id="action"> +</form> + {% if user.is_authenticated %} {% if user.is_staff or perms.client.approved %} {% if not empty %} @@ -24,40 +30,83 @@ <i class="material-icons">timelapse</i> {% elif doc.0.status == "ok" %} <i class="material-icons">check</i> + {% elif doc.0.status == "autosign" %} + <i class="material-icons">assignment_turned_in</i> {% endif %} {{doc.0.document_type.name}} - <span class="badge" data-badge-caption="">{{doc.0.compilation_date}}</span></div> + <span class="badge" data-badge-caption="">{{doc.0.compilation_date}}</span> </div> <div class="collapsible-body"><span> {% if doc.0.status == "wait" %} - <a class="waves-effect waves-light btn red lighten-1" href="{%url 'server'%}"><i class="material-icons left">file_download</i> Scarica documento per approvazione</a> - <a class="waves-effect waves-light btn red lighten-1" href="{%url 'server'%}"><i class="material-icons left">delete</i> Elimina documento</a> - <a class="waves-effect waves-light btn red lighten-1" href="{%url 'server'%}"><i class="material-icons left">edit</i> Modifica documento</a> + <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> + <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> <br> <br> {% endif %} + <ul class="collapsible"> {% if doc.0.document_type.personal_data %} - <i class="material-icons">person</i> + <li> + <div class="collapsible-header"> + <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> + </span></div> + </li> {% endif %} {% if doc.0.document_type.medical_data %} - <i class="material-icons">healing</i> + <li> + <div class="collapsible-header"> + <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> + </span></div> + </li> {% endif %} {% if doc.0.document_type.custom_data %} - <i class="material-icons">add_circle_outline</i> - {% endif %} - {% if doc.0.document_type.custom_data %} - <br> - <table class="striped"> - <tbody> - {% for key in doc.1 %} - <tr> - <td>{{key.key}}</td> - <td>{{key.value}}</td> - </tr> - {% endfor %} - </tbody> - </table> + <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.1 %} + <tr> + <td>{{key.key}}</td> + <td>{{key.value}}</td> + </tr> + {% endfor %} + </tbody> + </table> + </span></div> + </li> {% endif %} + </ul> </span></div> </li> {% endfor %} @@ -73,7 +122,7 @@ <div class="col l4 offset-l4 m8 offset-m2 s12"> <div class="card"> <div class="card-content"> - <p>Il tuo utente non e` ancora stato approvato.</p> + <p>Il tuo utente non è ancora stato approvato.</p> </div> <div class="card-action"> <a href="{% url 'approve' %}">Come farsi approvare l'utente</a> @@ -87,7 +136,7 @@ <div class="col l4 offset-l4 m8 offset-m2 s12"> <div class="card"> <div class="card-content"> - <p>Se hai gia` un account clicca login in alto a destra. Altrimenti clicca registrazione</p> + <p>Se hai già un account clicca login in alto a destra. Altrimenti clicca registrazione</p> </div> </div> </div> @@ -108,4 +157,10 @@ $('*').click(function(event) { $('.tap-target').tapTarget('close'); } }); +function send(id) { + var form = document.getElementById('form') + var action = document.getElementById('action') + action.setAttribute('value', id); + form.submit() +} {% endblock %}
\ No newline at end of file diff --git a/client/urls.py b/client/urls.py index b58433e..164eefc 100644 --- a/client/urls.py +++ b/client/urls.py @@ -6,4 +6,5 @@ urlpatterns = [ path('', views.index, name='index'), path('approve', views.approve, name='approve'), path('create', views.create, name='create'), + path('edit', views.edit, name='edit'), ] diff --git a/client/views.py b/client/views.py index f70d930..b610962 100644 --- a/client/views.py +++ b/client/views.py @@ -1,6 +1,6 @@ from random import randint from django.contrib.auth.models import Group, Permission, User -from client.models import UserCode, Keys, DocumentType, Document, PersonalData, KeyVal +from client.models import UserCode, Keys, DocumentType, Document, PersonalData, KeyVal, MedicalData from django.db.models import Q from django.http import HttpResponseRedirect @@ -19,17 +19,54 @@ def index(request): code = randint(100000, 999999) if len(UserCode.objects.filter(code=code)) == 0: break - userCode = UserCode(user=request.user, code=code) + medic = MedicalData() + medic.save() + userCode = UserCode(user=request.user, code=code, medic=medic) userCode.save() + if request.method == "POST": + document = Document.objects.get(id=request.POST["action"][1:]) + if request.POST["action"][0] == 'f': + pass + elif request.POST["action"][0] == 'a': + document.status = "ok" + document.save() + elif request.POST["action"][0] == 'd': + document.delete() + elif request.POST["action"][0] == 'e': + 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 + keys = Keys.objects.filter(container=document_type) + out_keys = [] + for i in keys: + out_keys.append([i, KeyVal.objects.filter(Q(container=document) & Q(key=i.key))[0].value]) + context['keys'] = out_keys + context['custom_message'] = document_type.custom_message + context['custom_message_text'] = document_type.custom_message_text + return edit_wrapper(request, context) + documents = Document.objects.filter(Q(user=request.user) & ~Q(status='archive')) out = [] for i in documents: - out.append([i, KeyVal.objects.filter(container=i)]) + personal = None + medical = None + if i.document_type.personal_data: + personal = i.personal_data.__dict__.values() + if i.document_type.medical_data: + medical = i.medical_data.__dict__.values() + + out.append([i, KeyVal.objects.filter(container=i), personal, medical]) context = { "docs": out, "empty": len(out) == 0, } + return render(request, 'client/index.html', context) @@ -45,7 +82,6 @@ def approve(request): else: return render(request, 'client/index.html', context) - def create(request): context = {} if request.user.is_authenticated: @@ -59,7 +95,7 @@ def create(request): if len(Document.objects.filter(Q(user=request.user) & Q(document_type=doc))) == 0: out.append(doc) - context = {'docs': out} + context['docs'] = out if request.method == "POST": if request.POST["action"] == "details": if "doctype" not in request.POST.keys(): @@ -85,31 +121,84 @@ def create(request): code = 0 status = "wait" personal_data = None + medical_data = None document_type = DocumentType.objects.get( id=request.POST["doctype"]) + + if document_type.auto_sign: + status = "autosign" + keys = [] if document_type.personal_data: - personal_data = PersonalData(parent_name=usercode.parent_name, via=usercode.via, cap=usercode.cap, country=usercode.country, + personal_data = PersonalData(email=request.user.email, parent_name=usercode.parent_name, via=usercode.via, cap=usercode.cap, country=usercode.country, nationality=usercode.nationality, born_date=usercode.born_date, home_phone=usercode.home_phone, phone=usercode.phone) personal_data.save() + if document_type.medical_data: + medic = usercode.medic + medical_data = MedicalData(emer_name=medic.emer_name, emer_relative=medic.emer_relative, cell_phone=medic.cell_phone, address=medic.address, emer_phone=medic.emer_phone, health_care=medic.health_care, injuries=medic.injuries, rc=medic.rc, rega=medic.rega, medic_name=medic.medic_name, medic_phone=medic.medic_phone, medic_address=medic.medic_address, sickness=medic.sickness, vaccine=medic.vaccine, tetanus_date=medic.tetanus_date, allergy=medic.allergy, drugs_bool=medic.drugs_bool, drugs=medic.drugs, misc_bool=medic.misc_bool, misc=medic.misc) + medical_data.save() + while (True): code = randint(100000, 999999) if len(Document.objects.filter(code=code)) == 0: break document = Document( - user=request.user, group=group, code=code, status=status, document_type=document_type, personal_data=personal_data) + user=request.user, group=group, code=code, status=status, document_type=document_type, personal_data=personal_data, medical_data=medical_data) document.save() - for i in request.POST.keys(): - if i == "doctype" or i=="csrfmiddlewaretoken" or i=="action": - continue - key = KeyVal(container=document, key=Keys.objects.get(id=i).key, value=request.POST[i]) - key.save() + if document_type.custom_data: + for i in request.POST.keys(): + if i == "doctype" or i=="csrfmiddlewaretoken" or i=="action": + continue + key = KeyVal(container=document, key=Keys.objects.get(id=i).key, value=request.POST[i]) + key.save() return HttpResponseRedirect('/') return render(request, 'client/doc_create.html', context) else: return render(request, 'client/index.html', context) + +def edit(request): + return edit_wrapper(request, {}) + +def edit_wrapper(request, context): + if request.user.is_authenticated: + if request.method == "POST": + if "action" not in request.POST.keys(): + document = Document.objects.get(id=request.POST["doc"]) + usercode = UserCode.objects.filter(user=document.user)[0] + + if document.document_type.personal_data: + personal_data = PersonalData(email=request.user.email, parent_name=usercode.parent_name, via=usercode.via, cap=usercode.cap, country=usercode.country, + nationality=usercode.nationality, born_date=usercode.born_date, home_phone=usercode.home_phone, phone=usercode.phone) + personal_data.save() + old_data = document.personal_data + document.personal_data = personal_data + document.save() + old_data.delete() + + if document.document_type.medical_data: + medic = usercode.medic + medical_data = MedicalData(emer_name=medic.emer_name, emer_relative=medic.emer_relative, cell_phone=medic.cell_phone, address=medic.address, emer_phone=medic.emer_phone, health_care=medic.health_care, injuries=medic.injuries, rc=medic.rc, rega=medic.rega, medic_name=medic.medic_name, medic_phone=medic.medic_phone, medic_address=medic.medic_address, sickness=medic.sickness, vaccine=medic.vaccine, tetanus_date=medic.tetanus_date, allergy=medic.allergy, drugs_bool=medic.drugs_bool, drugs=medic.drugs, misc_bool=medic.misc_bool, misc=medic.misc) + medical_data.save() + old_data = document.medical_data + document.medical_data = medical_data + document.save() + old_data.delete() + + if document.document_type.custom_data: + for i in request.POST.keys(): + if i == "doc" or i=="csrfmiddlewaretoken": + continue + key = KeyVal.objects.filter(Q(container=document) & Q(key=Keys.objects.get(id=i).key))[0] + key.value = request.POST[i] + key.save() + + return HttpResponseRedirect('/') + + return render(request, 'client/doc_edit.html', context) + else: + return render(request, 'client/index.html', context) diff --git a/server/templates/server/doc_edit.html b/server/templates/server/doc_create.html index 8b01c35..6454bee 100644 --- a/server/templates/server/doc_edit.html +++ b/server/templates/server/doc_create.html @@ -1,12 +1,12 @@ {% extends 'registration/base.html' %} -{% block title %}Admin - Modifica Tipo{% endblock %} +{% block title %}Admin - Crea Tipo{% endblock %} {% block nav %} <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a> <a href="{% url 'server'%}" class="breadcrumb hide-on-med-and-down">Admin</a> <a href="{% url 'doctype' %}" class="breadcrumb hide-on-med-and-down">Tipo Doc</a> - <a href="#!" class="breadcrumb hide-on-med-and-down">Modifica Doc</a> + <a href="#!" class="breadcrumb hide-on-med-and-down">Crea Tipo</a> {% endblock %} {% block content %} @@ -14,11 +14,11 @@ <div class="col l8 offset-l2 s12"> <div class="card-panel"> <div class="row"> - <form id="form" action="{% url 'docedit'%}" method="post" class="col s12"> + <form id="form" action="{% url 'doccreate'%}" method="post" class="col s12"> {% csrf_token %} <div class="row"> <div class="input-field col s12"> - <input name="name" value="{{name}}" id="name" type="text" class="validate"> + <input name="name" value="{{name}}" id="name" type="text"> <label for="name">Nome</label> </div> </div> @@ -39,6 +39,17 @@ Privato </label> </div> + <div class="switch col s3"> + <label> + Richiede firma + </label> + <label> + No + <input name="sign" type="checkbox" {{sign_check}}> + <span class="lever"></span> + Si + </label> + </div> </div> <div class="row"> <div class="input-field col s2"> diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html index c5978b1..0b3d800 100644 --- a/server/templates/server/doc_list.html +++ b/server/templates/server/doc_list.html @@ -51,36 +51,68 @@ <i class="material-icons">archive</i> {% endif %} {{doc.0.document_type.name}} - <span class="badge" data-badge-caption="">{{doc.0.user.username}}</span></div> + <span class="badge" data-badge-caption="">{{doc.0.user.username}}</span> </div> <div class="collapsible-body"><span> {{doc.0.code}} <br> {{doc.0.compilation_date}}<br> + <ul class="collapsible"> {% if doc.0.document_type.personal_data %} - <i class="material-icons">person</i> + <li> + <div class="collapsible-header"> + <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> + </span></div> + </li> {% endif %} {% if doc.0.document_type.medical_data %} - <i class="material-icons">healing</i> - {% endif %} - {% if doc.0.document_type.custom_message %} - <i class="material-icons">message</i> - {% endif %} - {% if doc.0.document_type.custom_data %} - <i class="material-icons">add_circle_outline</i> + <li> + <div class="collapsible-header"> + <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> + </span></div> + </li> {% endif %} {% if doc.0.document_type.custom_data %} - <br> - <table class="striped"> - <tbody> - {% for key in doc.1 %} - <tr> - <td>{{key.key}}</td> - <td>{{key.value}}</td> - </tr> - {% endfor %} - </tbody> - </table> + <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.1 %} + <tr> + <td>{{key.key}}</td> + <td>{{key.value}}</td> + </tr> + {% endfor %} + </tbody> + </table> + </span></div> + </li> {% endif %} + </ul> </span></div> </li> {% endfor %} diff --git a/server/templates/server/doc_type.html b/server/templates/server/doc_type.html index fecfc9d..15ac30e 100644 --- a/server/templates/server/doc_type.html +++ b/server/templates/server/doc_type.html @@ -48,41 +48,64 @@ {% if not doctype.0.group_private %} <i class="material-icons">public</i> {% endif %} + {% if doctype.0.auto_sign %} + <i class="material-icons">assignment_turned_in</i> + {% endif %} {{doctype.0.name}} - <span class="new badge red lighten-1" data-badge-caption="">{{doctype.2}}</span></div> + <span class="new badge red lighten-1" data-badge-caption="">{{doctype.2}}</span> </div> <div class="collapsible-body"><span> + <ul class="collapsible"> {% if doctype.0.personal_data %} - <i class="material-icons">person</i> + <li> + <div class="collapsible-header"> + <i class="material-icons">person</i>Dati personali + </div> + </li> {% endif %} {% if doctype.0.medical_data %} - <i class="material-icons">healing</i> - {% endif %} - {% if doctype.0.custom_data %} - <i class="material-icons">add_circle_outline</i> - {% endif %} - {% if doctype.0.custom_message %} - <i class="material-icons">message</i> + <li> + <div class="collapsible-header"> + <i class="material-icons">healing</i>Dati medici + </div> + </li> {% endif %} {% if doctype.0.custom_data %} - <br> - <ul class="collection"> - {% for key in doctype.1 %} - <li class="collection-item">{{key.key}}</li> - {% endfor %} - </ul> + <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 doctype.1 %} + <tr> + <td>{{key.key}}</td> + </tr> + {% endfor %} + </tbody> + </table> + </span></div> + </li> {% endif %} {% if doctype.0.custom_message %} - <br> - {{doctype.0.custom_message_text}} + <li> + <div class="collapsible-header"> + <i class="material-icons">message</i>Messaggio aggiuntivo + </div> + <div class="collapsible-body"><span> + {{doctype.0.custom_message_text}} + </span></div> + </li> {% endif %} + </ul> </span></div> </li> {% endfor %} </ul> </form> <div class="fixed-action-btn"> - <a class="btn-floating btn-large red lighten-1" href="{% url 'docedit'%}"> + <a class="btn-floating btn-large red lighten-1" href="{% url 'doccreate'%}"> <i class="large material-icons">add</i> </a> </div> diff --git a/server/templates/server/index.html b/server/templates/server/index.html index d88454f..199feb5 100644 --- a/server/templates/server/index.html +++ b/server/templates/server/index.html @@ -40,8 +40,21 @@ <div class="col l6 s12"> <div class="card large"> <div class="card-content"> - <p>I am a very simple card. I am good at containing small bits of information. - I am convenient because I require little markup to use effectively.</p> + <ul class="collapsible"> + {% for doctype in docs %} + <li> + <div class="collapsible-header"> + {% if not doctype.0.enabled %} + <i class="material-icons">visibility_off</i> + {% endif %} + {% if not doctype.0.group_private %} + <i class="material-icons">public</i> + {% endif %} + {{doctype.0.name}} + <span class="new badge red lighten-1" data-badge-caption="">{{doctype.1}}</span> + </div> + {% endfor %} + </ul> </div> <div class="card-action"> <a href="{% url 'doctype' %}">Lista tipo doc</a> diff --git a/server/urls.py b/server/urls.py index fb2c2f2..773d910 100644 --- a/server/urls.py +++ b/server/urls.py @@ -7,7 +7,7 @@ urlpatterns = [ path('uapprove', views.uapprove, name='uapprove'), path('ulist', views.ulist, name='ulist'), path('doctype', views.doctype, name='doctype'), - path('docedit', views.docedit, name='docedit'), + path('doccreate', views.doccreate, name='doccreate'), path('doclist', views.doclist, name='doclist'), path('docapprove', views.docapprove, name='docapprove'), ] diff --git a/server/views.py b/server/views.py index b59dfb8..6c651f1 100644 --- a/server/views.py +++ b/server/views.py @@ -14,7 +14,7 @@ def index(request): parent_group = request.user.groups.values_list('name', flat=True)[ 0] users = User.objects.filter(groups__name=parent_group) - out = [] + users_out = [] for user in users: code = "" if len(UserCode.objects.filter(user=user)) > 0: @@ -26,9 +26,23 @@ def index(request): status = "Attivo" else: status = "In attesa" - out.append([user.username, user.first_name, + users_out.append([user.username, user.first_name, user.last_name, code, status]) - context = {'users': out} + + parent_group = request.user.groups.values_list('name', flat=True)[ + 0] + group = Group.objects.get(name=parent_group) + public_types = DocumentType.objects.filter( + Q(group_private=False) | Q(group=group)) + docs = [] + for doc in public_types: + ref_docs = Document.objects.filter(document_type=doc) + docs.append([doc, len(ref_docs)]) + + context = { + 'docs': docs, + 'users': users_out, + } return render(request, 'server/index.html', context) else: return render(request, 'client/index.html', context) @@ -44,7 +58,6 @@ def uapprove(request): group = Group.objects.get(name=parent_group) permission = Permission.objects.get(codename='approved') data = request.POST["codes"] - data = "".join(data.split()) data.replace("\r", "") data = data.split("\n") for i in range(len(data)): @@ -88,7 +101,6 @@ def docapprove(request): data = [] if request.method == "POST": data = request.POST["codes"] - data = "".join(data.split()) data.replace("\r", "") data = data.split("\n") for i in range(len(data)): @@ -101,7 +113,7 @@ def docapprove(request): else: document = Document.objects.filter(code=data[i])[0] if document.status == 'ok': - data[i] = data[i] + " - Gia` approvato" + data[i] = data[i] + " - GiĆ approvato" else: document.status = 'ok' document.save() @@ -221,7 +233,7 @@ def doctype(request): return render(request, 'client/index.html', context) -def docedit(request): +def doccreate(request): context = {} if request.user.is_staff: parent_group = request.user.groups.values_list('name', flat=True)[ @@ -234,15 +246,17 @@ def docedit(request): custom_data = False name = "" - enabled_check = "" + enabled_check = 'checked="checked' private_check = 'checked="checked"' personal_check = 'checked="checked"' + sign_check = 'checked="checked' medical_check = "" custom_check = "" custom_message_check = "" context = { "enabled_check": enabled_check, "private_check": private_check, + "sign_check": sign_check, "personal_check": personal_check, "medical_check": medical_check, "custom_check": custom_check, @@ -250,6 +264,7 @@ def docedit(request): } if request.method == "POST": enabled = "enabled" in request.POST.keys() + auto_sign = "sign" not in request.POST.keys() group_private = "group_private" in request.POST.keys() personal_data = "personal_data" in request.POST.keys() medical_data = "medical_data" in request.POST.keys() @@ -257,18 +272,19 @@ def docedit(request): custom_message = "custom_message" in request.POST.keys() custom_message_text = request.POST["custom_message_text"] name = request.POST["name"] - custom = request.POST["custom"] - custom += " " - custom = custom.split("\n") doctype = DocumentType( - custom_message=custom_message, custom_message_text=custom_message_text, name=request.POST["name"], enabled=enabled, group_private=group_private, group=group, personal_data=personal_data, medical_data=medical_data, custom_data=custom_data) + auto_sign=auto_sign, custom_message=custom_message, custom_message_text=custom_message_text, name=request.POST["name"], enabled=enabled, group_private=group_private, group=group, personal_data=personal_data, medical_data=medical_data, custom_data=custom_data) doctype.save() - for i in custom: - key = Keys(key=i[:-1], container=doctype) - key.save() + if custom_data: + custom = request.POST["custom"] + custom.replace("\r", "") + custom = custom.split("\n") + for i in custom: + key = Keys(key=i, container=doctype) + key.save() return HttpResponseRedirect('doctype') - return render(request, 'server/doc_edit.html', context) + return render(request, 'server/doc_create.html', context) else: return render(request, 'client/index.html', context) @@ -305,8 +321,14 @@ def doclist(request): documents = Document.objects.filter(group=group) out = [] for i in documents: - custom_keys = KeyVal.objects.filter(container=i) - out.append([i, custom_keys]) + personal = None + medical = None + if i.document_type.personal_data: + personal = i.personal_data.__dict__.values() + if i.document_type.medical_data: + medical = i.medical_data.__dict__.values() + + out.append([i, KeyVal.objects.filter(container=i), personal, medical]) context = {"docs": out} return render(request, 'server/doc_list.html', context) else: |