From 5e4ab7a58a9b2dc70fab14467719f9c531e16b6d Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 23 Jul 2024 12:49:44 -0400 Subject: [PATCH] membershipworks: Use Non-Member ticket price when Member price is 0 --- membershipworks/models.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/membershipworks/models.py b/membershipworks/models.py index 80f56d1..431028c 100644 --- a/membershipworks/models.py +++ b/membershipworks/models.py @@ -687,25 +687,31 @@ class EventTicketTypeManager(models.Manager["EventTicketType"]): ) qs = super().get_queryset() return qs.annotate( + members_price=Subquery( + qs.filter(event=OuterRef("event"), restrict_to=members_folder).values( + "list_price" + ), + output_field=models.FloatField(), + ), # Before 2024-07-01, use Members ticket price for any # restricted ticket, but list price for unrestricted # (Non-Members) ticket. After, use Members ticket price - # for all tickets. + # for all tickets except where members ticket is free. actual_price=Case( When( + # member ticket Q(restrict_to=members_folder) | ( - Q(event__start__lt=datetime(year=2024, month=7, day=1)) - & Q(restrict_to__isnull=True) + # non-member ticket + Q(restrict_to__isnull=True) + & ( + Q(event__start__lt=datetime(year=2024, month=7, day=1)) + | Q(members_price=0) + ) ), "list_price", ), - default=Subquery( - qs.filter( - event=OuterRef("event"), restrict_to=members_folder - ).values("list_price"), - output_field=models.FloatField(), - ), + default="members_price", ), is_members_ticket=(Q(restrict_to__isnull=False)), materials=Case(