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 /server/views.py | |
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-- | server/views.py | 14 |
1 files changed, 12 insertions, 2 deletions
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)
|