Skip to content

Commit

Permalink
Hide alumni members for unauthed
Browse files Browse the repository at this point in the history
  • Loading branch information
julianweng committed Oct 11, 2024
1 parent 8acabe3 commit cdb599b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 2 additions & 0 deletions backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,8 @@ def alumni(self, request, *args, **kwargs):
type: string
---
"""
if not request.user.is_authenticated:
raise PermissionDenied
club = self.get_object()
results = collections.defaultdict(list)
for first, last, year, show, username in club.membership_set.filter(
Expand Down
13 changes: 11 additions & 2 deletions frontend/pages/club/[club]/alumni.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@ import { NextPageContext } from 'next'
import Link from 'next/link'
import { ReactElement } from 'react'
import renderPage from 'renderPage'
import { Club } from 'types'
import { Club, UserInfo } from 'types'
import { doApiRequest } from 'utils'

import AuthPrompt from '~/components/common/AuthPrompt'
import { CLUB_ROUTE, PROFILE_ROUTE } from '~/constants'

type AlumniPageProps = {
club: Club
userInfo?: UserInfo
alumni:
| { [year: string]: { name: string; username: string | null }[] }
| { detail: string }
}

const AlumniPage = ({ club, alumni }: AlumniPageProps): ReactElement => {
const AlumniPage = ({
club,
alumni,
userInfo,
}: AlumniPageProps): ReactElement => {
if (!userInfo) {
return <AuthPrompt />
}
return (
<>
<ClubMetadata club={club} />
Expand Down
24 changes: 13 additions & 11 deletions frontend/pages/club/[club]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,19 @@ const ClubPage = ({
<div className="mb-3">
<StrongText>Additional Pages</StrongText>
<ul>
<li>
<Link
legacyBehavior
href={CLUB_ALUMNI_ROUTE()}
as={CLUB_ALUMNI_ROUTE(club.code)}
>
<a>
<Icon name="database" /> Alumni
</a>
</Link>
</li>
{userInfo && (
<li>
<Link
legacyBehavior
href={CLUB_ALUMNI_ROUTE()}
as={CLUB_ALUMNI_ROUTE(club.code)}
>
<a>
<Icon name="database" /> Alumni
</a>
</Link>
</li>
)}
<li>
<Link
legacyBehavior
Expand Down

0 comments on commit cdb599b

Please sign in to comment.