Skip to content

Commit

Permalink
Revert changes to get_serializer_class
Browse files Browse the repository at this point in the history
  • Loading branch information
aviupadhyayula committed Sep 1, 2024
1 parent 9f47136 commit 8b7255e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2168,8 +2168,15 @@ def get_serializer_class(self):
return ClubSerializer
return ClubListSerializer
if self.request is not None and self.request.user.is_authenticated:
club = self.get_object() if "code" in self.kwargs else None
if club and self._has_elevated_view_perms(club):
see_pending = self.request.user.has_perm("clubs.see_pending_clubs")
manage_club = self.request.user.has_perm("clubs.manage_club")
is_member = (
"code" in self.kwargs
and Membership.objects.filter(
person=self.request.user, club__code=self.kwargs["code"]
).exists()
)
if see_pending or manage_club or is_member:
return AuthenticatedClubSerializer
return ClubSerializer

Expand Down

0 comments on commit 8b7255e

Please sign in to comment.