Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only show clubs that have been approved this school year (approximately) #731

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion backend/clubs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,28 @@ def to_representation(self, instance):
and instance.membership_set.filter(person=user).exists()
)
if not can_see_pending and not is_member:
if instance.approved is False:
raise serializers.ValidationError(
"This club has been removed from the platform."
)
# Given month and date APPROVAL_CUTOFF, find the last date
last_date = timezone.now().replace(
month=settings.APPROVAL_CUTOFF.tm_mon,
day=settings.APPROVAL_CUTOFF.tm_mday,
)
if timezone.now() < last_date:
last_date = last_date.replace(year=timezone.now().year - 1)

historical_club = (
instance.history.filter(approved=True)
.order_by("-approved_on")
.first()
)
if historical_club is not None:
if (
historical_club is not None
and historical_club.approved_on
and historical_club.approved_on < last_date
):
approved_instance = historical_club.instance
approved_instance._is_historical = True
return super().to_representation(approved_instance)
Expand Down
4 changes: 3 additions & 1 deletion backend/pennclubs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import os
import time

import dj_database_url

Expand Down Expand Up @@ -203,7 +204,8 @@
APPLY_URL = "https://{domain}/club/{club}/apply"

OSA_EMAILS = ["[email protected]"]

# Cut off date for reapproval per year
APPROVAL_CUTOFF = time.strptime("09-01", "%m-%d")

# Controls whether existing clubs can submit for reapproval
REAPPROVAL_QUEUE_OPEN = True
Expand Down
Loading