diff options
author | Andrea Lepori <alepori@student.ethz.ch> | 2020-06-20 23:32:55 +0200 |
---|---|---|
committer | Andrea Lepori <alepori@student.ethz.ch> | 2020-06-20 23:32:55 +0200 |
commit | 26fb6c43a27c014383127d0e4b3fb29f8b923690 (patch) | |
tree | 05fd542c342cf12cac72b49e5b4b44db7411d91a /server | |
parent | Document custom field (diff) | |
download | scout-subs-26fb6c43a27c014383127d0e4b3fb29f8b923690.tar.gz scout-subs-26fb6c43a27c014383127d0e4b3fb29f8b923690.zip |
Doc, doctypes, users all done
Diffstat (limited to '')
-rw-r--r-- | server/templates/server/doc_create.html (renamed from server/templates/server/doc_edit.html) | 19 | ||||
-rw-r--r-- | server/templates/server/doc_list.html | 72 | ||||
-rw-r--r-- | server/templates/server/doc_type.html | 59 | ||||
-rw-r--r-- | server/templates/server/index.html | 17 | ||||
-rw-r--r-- | server/urls.py | 2 | ||||
-rw-r--r-- | server/views.py | 58 |
6 files changed, 164 insertions, 63 deletions
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: |