aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2022-05-18 17:38:53 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2022-05-18 17:38:53 +0200
commitd11af9ba81ec53953f4503386e22fdaa40b6df04 (patch)
treecb58b43d2631b698de4ce29e86d6cad05c4d87ea /server
parentfix bug/typo on data request (diff)
downloadscout-subs-d11af9ba81ec53953f4503386e22fdaa40b6df04.tar.gz
scout-subs-d11af9ba81ec53953f4503386e22fdaa40b6df04.zip
fix csv download if no personal data
Diffstat (limited to 'server')
-rw-r--r--server/views.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/server/views.py b/server/views.py
index 928eac1..9dbc666 100644
--- a/server/views.py
+++ b/server/views.py
@@ -374,7 +374,9 @@ def doctype(request):
writer = csv.writer(response)
# csv header
- header = ["Nome", "Cognome", "Email", "Stato", "Data di compilazione", "Nome dei genitori", "Via", "CAP", "Comune", "Nazionalita", "Data di nascita", "Telefono di casa", "Telefono", "Scuola", "Anno scolastico", "Numero AVS"]
+ header = ["Nome", "Cognome", "Email", "Stato", "Data di compilazione"]
+ 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"]
if document_type.custom_data:
header += Keys.objects.filter(container=document_type).values_list("key", flat=True)
@@ -388,18 +390,21 @@ def doctype(request):
doc.user.email,
doc.status,
doc.compilation_date,
- doc.personal_data.parent_name,
- doc.personal_data.via,
- doc.personal_data.cap,
- doc.personal_data.country,
- doc.personal_data.nationality,
- doc.personal_data.born_date,
- doc.personal_data.home_phone,
- doc.personal_data.phone,
- doc.personal_data.school,
- doc.personal_data.year,
- doc.personal_data.avs_number
]
+ if document_type.personal_data:
+ write_data += [
+ doc.personal_data.parent_name,
+ doc.personal_data.via,
+ doc.personal_data.cap,
+ doc.personal_data.country,
+ doc.personal_data.nationality,
+ doc.personal_data.born_date,
+ doc.personal_data.home_phone,
+ doc.personal_data.phone,
+ doc.personal_data.school,
+ doc.personal_data.year,
+ doc.personal_data.avs_number
+ ]
if document_type.custom_data:
write_data += KeyVal.objects.filter(container=doc).values_list("value", flat=True)