diff options
author | Andrea Lepori <alepori@student.ethz.ch> | 2022-05-18 18:39:23 +0200 |
---|---|---|
committer | Andrea Lepori <alepori@student.ethz.ch> | 2022-05-18 18:39:23 +0200 |
commit | a46d5adcc9a1e2482a093c81a7c698dbd5d46791 (patch) | |
tree | f0c41e441f3e88b428294cd74cf4b04bd0f1e63c | |
parent | improve modal size on phone screens (diff) | |
download | scout-subs-a46d5adcc9a1e2482a093c81a7c698dbd5d46791.tar.gz scout-subs-a46d5adcc9a1e2482a093c81a7c698dbd5d46791.zip |
add support for heading in custom params
Diffstat (limited to '')
-rw-r--r-- | client/templates/client/doc_create.html | 10 | ||||
-rw-r--r-- | client/templates/client/doc_edit.html | 10 | ||||
-rw-r--r-- | client/templatetags/app_filter.py | 18 | ||||
-rw-r--r-- | server/views.py | 14 | ||||
-rw-r--r-- | version.txt | 2 |
5 files changed, 49 insertions, 5 deletions
diff --git a/client/templates/client/doc_create.html b/client/templates/client/doc_create.html index 71bdbbe..c42fa05 100644 --- a/client/templates/client/doc_create.html +++ b/client/templates/client/doc_create.html @@ -109,7 +109,13 @@ {% endif %} {% if custom_data %} {% for key in keys %} - {% if key.key_extra|first in '!' %} + {% if key.key_extra|is_heading %} + <div class="row"> + <div class="input-field col s12"> + <h6>{{key.key_extra|parse_heading}}</h6> + </div> + </div> + {% elif key.key_extra|is_multiple_choice %} <div class="row"> <div class="col s12"> {% with arr=key.key_extra|parse_multiple_choice %} @@ -123,6 +129,8 @@ {% endwith %} </div> </div> + {% elif key.key_extra|is_checkbox %} + checkbox {% else %} <div class="row"> <div class="input-field col s12"> diff --git a/client/templates/client/doc_edit.html b/client/templates/client/doc_edit.html index 40deb26..2cf3e24 100644 --- a/client/templates/client/doc_edit.html +++ b/client/templates/client/doc_edit.html @@ -65,7 +65,13 @@ {% endif %} {% if custom_data %} {% for key in keys %} - {% if key.key_extra|first in '!' %} + {% if key.key_extra|is_heading %} + <div class="row"> + <div class="input-field col s12"> + <h6>{{key.key_extra|parse_heading}}</h6> + </div> + </div> + {% elif key.key_extra|is_multiple_choice %} <div class="row"> <div class="col s12"> {% with arr=key.key_extra|parse_multiple_choice %} @@ -86,6 +92,8 @@ {% endwith %} </div> </div> + {% elif key.key_extra|is_checkbox %} + checkbox {% else %} <div class="row"> <div class="input-field col s12"> diff --git a/client/templatetags/app_filter.py b/client/templatetags/app_filter.py index ed44138..5385852 100644 --- a/client/templatetags/app_filter.py +++ b/client/templatetags/app_filter.py @@ -38,6 +38,18 @@ def doc_count(doc): return doc_count +@register.filter(name="is_multiple_choice") +def is_multiple_choice(str): + return str.startswith("!m") + +@register.filter(name="is_checkbox") +def is_checkbox(str): + return str.startswith("!c") + +@register.filter(name="is_heading") +def is_heading(str): + return str.startswith("!h") + @register.filter(name="parse_multiple_choice") def parse_multiple_choice(str): if len(str) < 3: @@ -50,6 +62,12 @@ def parse_multiple_choice(str): return [arr[0], arr[1:]] +@register.filter(name="parse_heading") +def parse_heading(str): + if len(str) < 3: + return str + return str[3:] + @register.filter(name="parse_userswitcher") def parse_userswitcher(str): if not str: diff --git a/server/views.py b/server/views.py index 9dbc666..f8b0865 100644 --- a/server/views.py +++ b/server/views.py @@ -378,8 +378,10 @@ def doctype(request): if document_type.personal_data:
header += ["Nome dei genitori", "Via", "CAP", "Comune", "Nazionalita", "Data di nascita", "Telefono di casa", "Telefono", "Scuola", "Anno scolastico", "Numero AVS"]
+ keys = []
if document_type.custom_data:
- header += Keys.objects.filter(container=document_type).values_list("key", flat=True)
+ keys = Keys.objects.filter(container=document_type).values_list("key", flat=True)
+ header += keys
writer.writerow(header)
@@ -407,7 +409,15 @@ def doctype(request): ]
if document_type.custom_data:
- write_data += KeyVal.objects.filter(container=doc).values_list("value", flat=True)
+ # add empty cell if no keyval present
+ keyvals = KeyVal.objects.filter(container=doc).values_list("key", "value")
+ for key in keys:
+ for keyval in keyvals:
+ if keyval[0] == key:
+ write_data.append(keyval[1])
+ break
+ else:
+ write_data.append("")
writer.writerow(write_data)
diff --git a/version.txt b/version.txt index 6acbe2c..a68a900 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.5 -rev=21 +rev=22 |