diff options
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/templates/accounts/index.html | 211 | ||||
-rw-r--r-- | accounts/views.py | 53 |
2 files changed, 245 insertions, 19 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) |