diff options
author | Andrea Lepori <alepori@student.ethz.ch> | 2022-05-31 17:25:01 +0200 |
---|---|---|
committer | Andrea Lepori <alepori@student.ethz.ch> | 2022-05-31 17:25:01 +0200 |
commit | 9099d4729b4ff66786d2399bd978c0b460a5bb69 (patch) | |
tree | c9f93e9e7004797dcdbca12e39e0174a9e02a112 | |
parent | get complete list of documents for the user (diff) | |
download | scout-subs-9099d4729b4ff66786d2399bd978c0b460a5bb69.tar.gz scout-subs-9099d4729b4ff66786d2399bd978c0b460a5bb69.zip |
brackets substitution for type icons
Diffstat (limited to '')
-rw-r--r-- | server/views.py | 17 | ||||
-rw-r--r-- | version.txt | 2 |
2 files changed, 17 insertions, 2 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
diff --git a/version.txt b/version.txt index 03a6f3c..8e1f798 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.5 -rev=31 +rev=32 |