-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add export for participant requests #3578
base: main
Are you sure you want to change the base?
Conversation
|
||
class RegistrationRequestViewSet(mixins.ListModelMixin, GenericViewSet): | ||
serializer_class = RegistrationRequestSerializer | ||
permission_classes = [IsAuthenticated] |
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.
This should have object based permissions, otherwise this is all public information.
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.
There are permission checks in the get_queryset. Currently, we don't have any "view_registrationrequest"
permissions being assigned to the challenge.admins_groups. Should we? If so, I'll create a PR + manual call to have them added first, before doing anything that relies on them.
from rest_framework_csv.renderers import PaginatedCSVRenderer | ||
|
||
|
||
class RegistrationRequestCSVRenderer(PaginatedCSVRenderer): |
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.
Rather than flattening stuff with a special renderer why not serialize the answers instead?
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.
It was 50/50. I had the answers as a Charfield
initially, but it felt really strange to have a JSON string in a JSON object for the regular API.
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.
That's what it is though - it is a JSON field so in the future may not necessarily be a string. I think it is best to take the same approach as the evaluation serialisation and serialise things on the answer level, rather than the registration request. Permissions are already implemented for that so is less impact. You would then get some duplicate data that is serialised along with each answer (e.g. the username, the request status, the question text) but that is okay for now, it's not much.
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.
Do you mean to have a CSV row per answer?
If so, what about registrees that did not answer any questions? IMHO they should be included in any challenge registration overview. Plus, there are no permissions for the RegistrationQuestionAnswer
s.
Permissions are already implemented for that so is less impact.
Are you referring to the permissions for the RegistrationQuestionAnswer
s? Those were deemed to be overkill and were removed from the original implementation.
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.
Empty answers are saved for users that don't answer, right? The permissions weren't added because they weren't needed. Now they are needed if you want to add this view in line with the existing framework. We should do that rather than trying to fight it with custom renderers specific to one particular field.
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.
Empty answers are indeed saved (by design), but if there are no questions at the time of sign-up, the registree would now show up in an answer-level serialization.
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.
Then add another viewset, serialiser and permissions for the registration requests and link to those from the answers.
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.
Ok. The current plan (somewhere in the next cooldown week) is to have two routes:
- Link for downloading the registration requests.
- Link for downloading the answers to question registrations (with a crosslink to the registration requests).
Side note: is the swagger view supposed to work in local development? |
Set the environment variable |
Making this a draft to clearly indicate that this is WIP and been put on the backburner for now. |
Note
This is in a first reviewable state. However, I am pausing development on this and switching to cycle work. So any work following reviews will be delayed. Feel free to delay the review as you see fit.
Export of participant requests
This PR adds an export via API for participants' requests.
The JSON format:
The CSV format has the following headers:
The default CSV renderer dumps any JSON under the top level. I have intentionally switched to using the 'regular'
PaginatedCSVRender
with a special application forregistration_question_answers
. This is to address any strange rendering of actual JSONField values.