Skip to content

Commit

Permalink
Fix non-admin case
Browse files Browse the repository at this point in the history
  • Loading branch information
julianweng committed Nov 11, 2024
1 parent c6861cc commit 8867434
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/clubs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2987,7 +2987,10 @@ def get_approved_by(self, obj):
if not user.is_authenticated:
return None

Check warning on line 2988 in backend/clubs/serializers.py

View check run for this annotation

Codecov / codecov/patch

backend/clubs/serializers.py#L2988

Added line #L2988 was not covered by tests
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

Check warning on line 2993 in backend/clubs/serializers.py

View check run for this annotation

Codecov / codecov/patch

backend/clubs/serializers.py#L2993

Added line #L2993 was not covered by tests
if obj.approved_by is None:
return "Unknown"
return obj.approved_by.get_full_name()

Check warning on line 2996 in backend/clubs/serializers.py

View check run for this annotation

Codecov / codecov/patch

backend/clubs/serializers.py#L2996

Added line #L2996 was not covered by tests
Expand Down
3 changes: 3 additions & 0 deletions frontend/components/ClubPage/ClubApprovalDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -182,6 +184,7 @@ const ClubApprovalDialog = ({ club }: Props): ReactElement | null => {
setHistory(lastVersions)
})
}

setComment(
selectedTemplates.map((template) => template.content).join('\n\n'),
)
Expand Down

0 comments on commit 8867434

Please sign in to comment.