-
Notifications
You must be signed in to change notification settings - Fork 25
Add downlad attendee-csv-file EventViewSet #3811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
e3915d6 to
f2dec6b
Compare
9c7d5dc to
7ceff55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! 📈
| @decorators.action(detail=True, methods=["GET"]) | ||
| def csv(self, *args, **kwargs): | ||
| event = Event.objects.get(pk=kwargs["pk"]) | ||
| response = HttpResponse(content_type="text/csv") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use Response instead like other places in our codebase for consistency?
7ceff55 to
23ea776
Compare
23ea776 to
1d59af9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good job. Just some small nitpicks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove these two
| ) | ||
|
|
||
| writer = csv.writer(response) | ||
| writer.writerow(["full_name", "username", "email", "phone", "grade"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not phone_number here?
| event = Event.objects.get(pk=kwargs["pk"]) | ||
| response = HttpResponse(content_type="text/csv") | ||
| response["Content-Disposition"] = ( | ||
| f'attachment; filename="{event.title.replace(" ", "_") + "_attendees"}.csv"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this to filename="{event.title.replace(" ", "_") }_attendees.csv"
Description
Add csv action on EventViewSet
Testing
Please describe what and how the changes have been tested, and provide instructions to reproduce if necessary.
Resolves ABA-870