Skip to content

Commit

Permalink
Add route for club approval history (in-progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianweng committed Nov 4, 2024
1 parent 63c7a7d commit e507f13
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,18 @@ def upload_file(self, request, *args, **kwargs):

return file_upload_endpoint_helper(request, code=club.code)

@action(detail=True, methods=["get"])
def history(self, request, *args, **kwargs):
"""
Return a simplified approval history for the club.
"""
club = self.get_object()
return Response(
club.history.order_by("approved_on").values(
"approved", "approved_on", "approved_by", "history_date"
)
)

@action(detail=True, methods=["get"])
def owned_badges(self, request, *args, **kwargs):
"""
Expand Down
12 changes: 12 additions & 0 deletions frontend/components/ClubPage/ClubApprovalDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ type ConfirmParams = {
message: ReactElement | string
}

type HistoricItem = {
approved: boolean | null
approved_on: string | null
approved_by: string | null
history_date: string
}

const ClubApprovalDialog = ({ club }: Props): ReactElement | null => {
const router = useRouter()
const year = getCurrentSchoolYear()
const [history, setHistory] = useState<HistoricItem[]>([])
const [comment, setComment] = useState<string>(club.approved_comment || '')
const [loading, setLoading] = useState<boolean>(false)
const [confirmModal, setConfirmModal] = useState<ConfirmParams | null>(null)
Expand Down Expand Up @@ -62,6 +70,10 @@ const ClubApprovalDialog = ({ club }: Props): ReactElement | null => {
doApiRequest('/templates/?format=json')
.then((resp) => resp.json())
.then(setTemplates)

doApiRequest(`/clubs/${club.code}/history/?format=json`)
.then((resp) => resp.json())
.then(setHistory)
}

setComment(
Expand Down

0 comments on commit e507f13

Please sign in to comment.