Skip to content

Commit

Permalink
File Download - cosmatic changes
Browse files Browse the repository at this point in the history
Application Status - using the label rather than value
Datetime to date format.
  • Loading branch information
jinnashravan committed Nov 11, 2024
1 parent 0a2ea09 commit c841773
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion request_a_govuk_domain/request/admin/model_admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,18 @@ def export(self, _request, queryset):

writer.writerow(field_names)
for obj in queryset:
writer.writerow([getattr(obj, field) for field in field_names])
writer.writerow([self.format_field(obj, field) for field in field_names])

return response

def format_field(self, obj, field):
field_value = getattr(obj, field)
if field == "status":
field_value = ApplicationStatus(field_value).label
elif type(field_value) is datetime:
field_value = field_value.strftime("%Y-%m-%d")
return field_value

def has_export_permission(self, request, obj=None):
return request.user.is_superuser

Expand Down

0 comments on commit c841773

Please sign in to comment.