diff --git a/backend/clubs/serializers.py b/backend/clubs/serializers.py index 492ca171d..aa8575378 100644 --- a/backend/clubs/serializers.py +++ b/backend/clubs/serializers.py @@ -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) diff --git a/backend/pennclubs/settings/base.py b/backend/pennclubs/settings/base.py index 4c645ea94..79fa008f2 100644 --- a/backend/pennclubs/settings/base.py +++ b/backend/pennclubs/settings/base.py @@ -11,6 +11,7 @@ """ import os +import time import dj_database_url @@ -203,7 +204,8 @@ APPLY_URL = "https://{domain}/club/{club}/apply" OSA_EMAILS = ["vpul-orgs@pobox.upenn.edu"] - +# 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