aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2022-05-31 17:25:01 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2022-05-31 17:25:01 +0200
commit9099d4729b4ff66786d2399bd978c0b460a5bb69 (patch)
treec9f93e9e7004797dcdbca12e39e0174a9e02a112 /server
parentget complete list of documents for the user (diff)
downloadscout-subs-9099d4729b4ff66786d2399bd978c0b460a5bb69.tar.gz
scout-subs-9099d4729b4ff66786d2399bd978c0b460a5bb69.zip
brackets substitution for type icons
Diffstat (limited to '')
-rw-r--r--server/views.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/server/views.py b/server/views.py
index 601bd0f..a54c588 100644
--- a/server/views.py
+++ b/server/views.py
@@ -1,3 +1,4 @@
+import re
from django.shortcuts import render
from client.models import UserCode, Keys, DocumentType, Document, KeyVal
from django.conf import settings
@@ -648,7 +649,21 @@ def doccreate(request):
custom_message = "custom_message" in request.POST.keys()
staff_only = "staff_only" in request.POST.keys()
custom_message_text = request.POST["custom_message_text"]
+
+ # parse name with icons
name = request.POST["name"]
+ if "<" in name:
+ context["error"] = "true"
+ context["error_text"] = "Il nome non puo' contenere il carattere <"
+ return render(request, 'server/doc_create.html', context)
+
+ reg = r'\{[\s\S]*\}'
+ name_split = re.split(reg, name)
+ name_matches = re.findall(reg, name)
+ name_matches = list(map(lambda x: "<i class='material-icons'>" + x[1:len(x)-1] + "</i>", name_matches)) + [""]
+ name_arr = [val for pair in zip(name_split, name_matches) for val in pair]
+ name = "".join(name_arr)
+
custom_group = request.POST["custom_group"]
if request.POST["max_instances"]:
@@ -687,7 +702,7 @@ def doccreate(request):
# create type
doctype = DocumentType(
- custom_group=custom_group_bool, 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, staff_only=staff_only, max_instances=max_instances)
+ custom_group=custom_group_bool, auto_sign=auto_sign, custom_message=custom_message, custom_message_text=custom_message_text, name=name, enabled=enabled, group_private=group_private, group=group, personal_data=personal_data, medical_data=medical_data, custom_data=custom_data, staff_only=staff_only, max_instances=max_instances)
doctype.save()
# create custom keys