-
Notifications
You must be signed in to change notification settings - Fork 1
Permissions for recruitmentapplicationforapplicantview #1860
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?
Permissions for recruitmentapplicationforapplicantview #1860
Conversation
…e owner of the application to read or updated. Any authenticated user can update. Overrides destroy, partial_update and create to dissalow DELETE, PATCH and POST. Creating an application uses PUT.
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.
Se docs eksempel
https://www.django-rest-framework.org/api-guide/viewsets/
def destroy(self, request: Request, *args: tuple, **kwargs: dict[str, Any]) -> Response: | ||
"""Override destroy method to disallow deletion""" | ||
return Response({'detail': 'DELETE operation not allowed.'}, status=status.HTTP_405_METHOD_NOT_ALLOWED) | ||
|
||
def partial_update(self, request: Request, *args: tuple, **kwargs: dict[str, Any]) -> Response: | ||
"""Override partial_update method to disallow PATCH requests""" | ||
return Response({'detail': 'PATCH operation not allowed.'}, status=status.HTTP_405_METHOD_NOT_ALLOWED) | ||
|
||
def create(self, request: Request, *args: tuple, **kwargs: dict[str, Any]) -> Response: | ||
"""Override create method to disallow POST requests""" | ||
# We only PUT; in the update method contains logic for saving a new application | ||
return Response({'detail': 'POST operation not allowed.'}, status=status.HTTP_405_METHOD_NOT_ALLOWED) |
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.
TL;DR: dette bør ikke være nødvendig
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.
To much vibecode, will fix
No permissions needed, just filter queryset by authenticated user.
Refactors RecruitmentApplicationForApplicantView to only allow for the owner of the application to read or updated. Any authenticated user can update.
Overrides destroy, partial_update and create to dissalow DELETE, PATCH and POST.
Creating an application uses PUT.
Overrides DRFs' get_queryset to only return applications created by the authenticated user.
💡 Kind of unrelated: deleted a duplicate API function in api.ts, we had two for the same endpoint and HTTP method, but only one was in use.
close #1723