From 88674348293b93c2a11010c12c8cdda346a9ceef Mon Sep 17 00:00:00 2001 From: Julian Weng Date: Mon, 11 Nov 2024 02:45:32 -0500 Subject: [PATCH] Fix non-admin case --- backend/clubs/serializers.py | 5 ++++- frontend/components/ClubPage/ClubApprovalDialog.tsx | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/clubs/serializers.py b/backend/clubs/serializers.py index 0a21f11d6..d7dd7071b 100644 --- a/backend/clubs/serializers.py +++ b/backend/clubs/serializers.py @@ -2987,7 +2987,10 @@ def get_approved_by(self, obj): if not user.is_authenticated: return None if not user.has_perm("clubs.see_pending_clubs"): - return None + club = Club.objects.get(code=obj.code) + membership = Membership.objects.filter(person=user, club=club).first() + if membership is None or membership.role < Membership.ROLE_OFFICER: + return None if obj.approved_by is None: return "Unknown" return obj.approved_by.get_full_name() diff --git a/frontend/components/ClubPage/ClubApprovalDialog.tsx b/frontend/components/ClubPage/ClubApprovalDialog.tsx index 74eacd1df..76d645bd1 100644 --- a/frontend/components/ClubPage/ClubApprovalDialog.tsx +++ b/frontend/components/ClubPage/ClubApprovalDialog.tsx @@ -164,7 +164,9 @@ const ClubApprovalDialog = ({ club }: Props): ReactElement | null => { doApiRequest('/templates/?format=json') .then((resp) => resp.json()) .then(setTemplates) + } + if (isOfficer || canApprove) { doApiRequest(`/clubs/${club.code}/history/?format=json`) .then((resp) => resp.json()) .then((data) => { @@ -182,6 +184,7 @@ const ClubApprovalDialog = ({ club }: Props): ReactElement | null => { setHistory(lastVersions) }) } + setComment( selectedTemplates.map((template) => template.content).join('\n\n'), )