From 26fb6c43a27c014383127d0e4b3fb29f8b923690 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Sat, 20 Jun 2020 23:32:55 +0200 Subject: Doc, doctypes, users all done --- server/templates/server/doc_create.html | 103 ++++++++++++++++++++++++++++++++ server/templates/server/doc_edit.html | 92 ---------------------------- server/templates/server/doc_list.html | 72 +++++++++++++++------- server/templates/server/doc_type.html | 59 ++++++++++++------ server/templates/server/index.html | 17 +++++- server/urls.py | 2 +- server/views.py | 58 ++++++++++++------ 7 files changed, 252 insertions(+), 151 deletions(-) create mode 100644 server/templates/server/doc_create.html delete mode 100644 server/templates/server/doc_edit.html (limited to 'server') diff --git a/server/templates/server/doc_create.html b/server/templates/server/doc_create.html new file mode 100644 index 0000000..6454bee --- /dev/null +++ b/server/templates/server/doc_create.html @@ -0,0 +1,103 @@ +{% extends 'registration/base.html' %} + +{% block title %}Admin - Crea Tipo{% endblock %} + +{% block nav %} + Home + Admin + Tipo Doc + Crea Tipo +{% endblock %} + +{% block content %} +
+
+
+
+
+ {% csrf_token %} +
+
+ + +
+
+
+
+ +
+
+ +
+
+ + +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/server/templates/server/doc_edit.html b/server/templates/server/doc_edit.html deleted file mode 100644 index 8b01c35..0000000 --- a/server/templates/server/doc_edit.html +++ /dev/null @@ -1,92 +0,0 @@ -{% extends 'registration/base.html' %} - -{% block title %}Admin - Modifica Tipo{% endblock %} - -{% block nav %} - Home - Admin - Tipo Doc - Modifica Doc -{% endblock %} - -{% block content %} -
-
-
-
-
- {% csrf_token %} -
-
- - -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
- -
-
- -
-
-
-
-
- - -
-
-
-
- - -
-
- -
-
-
-
-
-{% endblock %} \ No newline at end of file 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 @@ archive {% endif %} {{doc.0.document_type.name}} - {{doc.0.user.username}} + {{doc.0.user.username}}
{{doc.0.code}}
{{doc.0.compilation_date}}
+
    {% if doc.0.document_type.personal_data %} - person +
  • +
    + personDati personali +
    +
    + + + {% for field in doc.2 %} + + + + {% endfor %} + +
    {{field}}
    +
    +
  • {% endif %} {% if doc.0.document_type.medical_data %} - healing - {% endif %} - {% if doc.0.document_type.custom_message %} - message - {% endif %} - {% if doc.0.document_type.custom_data %} - add_circle_outline +
  • +
    + healingDati medici +
    +
    + + + {% for field in doc.3 %} + + + + {% endfor %} + +
    {{field}}
    +
    +
  • {% endif %} {% if doc.0.document_type.custom_data %} -
    - - - {% for key in doc.1 %} - - - - - {% endfor %} - -
    {{key.key}}{{key.value}}
    +
  • +
    + add_circle_outlineDati aggiuntivi +
    +
    + + + {% for key in doc.1 %} + + + + + {% endfor %} + +
    {{key.key}}{{key.value}}
    +
    +
  • {% endif %} +
{% 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 %} public {% endif %} + {% if doctype.0.auto_sign %} + assignment_turned_in + {% endif %} {{doctype.0.name}} - {{doctype.2}} + {{doctype.2}}
+
    {% if doctype.0.personal_data %} - person +
  • +
    + personDati personali +
    +
  • {% endif %} {% if doctype.0.medical_data %} - healing - {% endif %} - {% if doctype.0.custom_data %} - add_circle_outline - {% endif %} - {% if doctype.0.custom_message %} - message +
  • +
    + healingDati medici +
    +
  • {% endif %} {% if doctype.0.custom_data %} -
    -
      - {% for key in doctype.1 %} -
    • {{key.key}}
    • - {% endfor %} -
    +
  • +
    + add_circle_outlineDati aggiuntivi +
    +
    + + + {% for key in doctype.1 %} + + + + {% endfor %} + +
    {{key.key}}
    +
    +
  • {% endif %} {% if doctype.0.custom_message %} -
    - {{doctype.0.custom_message_text}} +
  • +
    + messageMessaggio aggiuntivo +
    +
    + {{doctype.0.custom_message_text}} +
    +
  • {% endif %} +
{% endfor %}
- + add
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 @@
-

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.

+
    + {% for doctype in docs %} +
  • +
    + {% if not doctype.0.enabled %} + visibility_off + {% endif %} + {% if not doctype.0.group_private %} + public + {% endif %} + {{doctype.0.name}} + {{doctype.1}} +
    + {% endfor %} +
Lista tipo doc 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: -- cgit v1.2.1