csv export: support for bools and lists
authorJan Szejko <jan.szejko@gmail.com>
Mon, 9 May 2016 14:43:29 +0000 (16:43 +0200)
committerJan Szejko <jan.szejko@gmail.com>
Mon, 9 May 2016 14:43:29 +0000 (16:43 +0200)
contact/admin.py

index 7581666..0a0aaa0 100644 (file)
@@ -157,6 +157,11 @@ def extract_view(request, form_tag, extract_type_slug):
                 for key in keys:
                     if key not in record:
                         record[key] = ''
+                    if isinstance(record[key], bool):
+                        record[key] = 'tak' if record[key] else 'nie'
+                    if isinstance(record[key], (list, tuple)):
+                        record[key] = '; '.join(record[key])
+
                 csv_writer.writerow([record[key] for key in keys])
         csv_writer.writerow([])