Skip to content
Snippets Groups Projects
Verified Commit 4101d1d1 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Extend export CSV files with names and email adresses

parent aa3d60ca
No related branches found
No related tags found
No related merge requests found
......@@ -535,11 +535,7 @@ class ConfigureProfileView(PermissionRequiredMixin, SuccessMessageMixin, ModelFo
class CommentExportView(CSVExportView):
model = Comment
permission_required = "export_rankings_predicate"
fields = (
"person",
"text",
"author",
)
fields = ("person", "person__person__email", "text", "author", "author__person__email")
def get_filename(self, queryset):
return get_date_filename("comments")
......@@ -562,7 +558,15 @@ class ProfileExportView(PermissionRequiredMixin, CSVExportView):
return get_date_filename("profiles")
def get_fields(self, queryset):
return ("person", "nickname", "current_picture", "old_picture",) + tuple(
return (
"person",
"first_name",
"last_name",
"email",
"nickname",
"current_picture",
"old_picture",
) + tuple(
f"field_{val}"
for val in AdditionalProfileField.objects.all().values_list("id", flat=True)
)
......@@ -586,6 +590,8 @@ class ProfileExportView(PermissionRequiredMixin, CSVExportView):
if field_name.startswith("field_"):
id_ = int(field_name.split("_")[-1])
return AdditionalProfileField.objects.get(id=id_).name
elif field_name in ("first_name", "last_name", "email"):
return field_name
else:
return super().get_header_name(model, field_name)
......@@ -594,6 +600,9 @@ class ProfileExportView(PermissionRequiredMixin, CSVExportView):
return getattr(obj, field_name)
elif field_name == "person":
return obj.person.name
elif field_name in ("first_name", "last_name", "email"):
if hasattr(obj.person, "person"):
return getattr(obj.person.person, field_name, "")
else:
return super().get_field_value(obj, field_name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment