Skip to content

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Snorre98
Copy link
Contributor

@Snorre98 Snorre98 commented Apr 2, 2025

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

Snorre98 added 5 commits April 2, 2025 08:02
…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.
@Snorre98 Snorre98 linked an issue Apr 2, 2025 that may be closed by this pull request
@Snorre98 Snorre98 self-assigned this Apr 2, 2025
Copy link
Contributor

@Mathias-a Mathias-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +344 to +355
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)
Copy link
Contributor

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

Copy link
Contributor Author

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

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.

permissions for RecruitmentApplicationForApplicantView
2 participants