Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
851ee4f4
Commit
851ee4f4
authored
Nov 14, 2018
by
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/members/admin.py
View file @
851ee4f4
...
...
@@ -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;
\
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment