From dc3de21c4f6a4d407fa4ba392b486a231f013c51 Mon Sep 17 00:00:00 2001 From: Julian Weng Date: Sun, 29 Sep 2024 12:32:36 -0400 Subject: [PATCH 1/2] Only show clubs that have been approved this school year (approximately) --- backend/pennclubs/settings/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 From e37cca4ebd69542eac0e9bca675ab1b8166055d8 Mon Sep 17 00:00:00 2001 From: Julian Weng Date: Sun, 29 Sep 2024 12:37:37 -0400 Subject: [PATCH 2/2] Add actual backend change :( --- backend/clubs/serializers.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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)