Skip to content

Commit

Permalink
Add actual backend change :(
Browse files Browse the repository at this point in the history
  • Loading branch information
julianweng committed Sep 29, 2024
1 parent dc3de21 commit e37cca4
Showing 1 changed file with 17 additions and 1 deletion.
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

0 comments on commit e37cca4

Please sign in to comment.