Commit 851ee4f4 authored by Luko van der Maas's avatar Luko van der Maas
Browse files

Merge branch 'feature/member-email-export' into 'master'

Add email address CSV export feature

Closes #768

See merge request !1054
parents 6c715a94 b9a9b156
......@@ -92,7 +92,8 @@ class UserAdmin(BaseUserAdmin):
form = forms.UserChangeForm
add_form = forms.UserCreationForm
actions = ['address_csv_export', 'student_number_csv_export']
actions = ['address_csv_export', 'student_number_csv_export',
'email_csv_export']
inlines = (ProfileInline, MembershipInline,)
list_filter = (MembershipTypeListFilter,
......@@ -109,6 +110,21 @@ class UserAdmin(BaseUserAdmin):
}),
)
def email_csv_export(self, request, queryset):
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment;\
filename="email.csv"'
writer = csv.writer(response)
writer.writerow([_('First name'), _('Last name'), _('Email')])
for user in queryset:
writer.writerow([user.first_name,
user.last_name,
user.email,
])
return response
email_csv_export.short_description = _('Download email addresses for '
'selected users')
def address_csv_export(self, request, queryset):
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment;\
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment