Skip to content

Conversation

@emillub
Copy link
Contributor

@emillub emillub commented Mar 26, 2025

Description

Add csv action on EventViewSet

Testing

  • The code quality is at a minimum required level of quality, readability, and performance.
  • I have thoroughly tested my changes.

Please describe what and how the changes have been tested, and provide instructions to reproduce if necessary.

Resolves ABA-870

@linear
Copy link

linear bot commented Mar 26, 2025

@emillub emillub force-pushed the add-export-participants-to-csv branch from e3915d6 to f2dec6b Compare March 26, 2025 20:50
@emillub emillub force-pushed the add-export-participants-to-csv branch 2 times, most recently from 9c7d5dc to 7ceff55 Compare March 26, 2025 20:56
Copy link
Member

@jonasdeluna jonasdeluna left a 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")
Copy link
Member

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?

@emillub emillub force-pushed the add-export-participants-to-csv branch from 7ceff55 to 23ea776 Compare March 26, 2025 21:00
@emillub emillub force-pushed the add-export-participants-to-csv branch from 23ea776 to 1d59af9 Compare March 26, 2025 21:03
Copy link
Contributor

@Arashfa0301 Arashfa0301 left a 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

Comment on lines +363 to +364
Copy link
Contributor

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"])
Copy link
Contributor

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"'
Copy link
Contributor

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants