membershipworks: Use Non-Member ticket price when Member price is 0
Some checks failed
Ruff / ruff (push) Successful in 1m36s
Test / test (push) Failing after 3m35s

This commit is contained in:
Adam Goldsmith 2024-07-23 12:49:44 -04:00
parent b60d9f6644
commit 5e4ab7a58a

View File

@ -687,25 +687,31 @@ class EventTicketTypeManager(models.Manager["EventTicketType"]):
) )
qs = super().get_queryset() qs = super().get_queryset()
return qs.annotate( 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 # Before 2024-07-01, use Members ticket price for any
# restricted ticket, but list price for unrestricted # restricted ticket, but list price for unrestricted
# (Non-Members) ticket. After, use Members ticket price # (Non-Members) ticket. After, use Members ticket price
# for all tickets. # for all tickets except where members ticket is free.
actual_price=Case( actual_price=Case(
When( When(
# member ticket
Q(restrict_to=members_folder) Q(restrict_to=members_folder)
| ( | (
# non-member ticket
Q(restrict_to__isnull=True)
& (
Q(event__start__lt=datetime(year=2024, month=7, day=1)) Q(event__start__lt=datetime(year=2024, month=7, day=1))
& Q(restrict_to__isnull=True) | Q(members_price=0)
)
), ),
"list_price", "list_price",
), ),
default=Subquery( default="members_price",
qs.filter(
event=OuterRef("event"), restrict_to=members_folder
).values("list_price"),
output_field=models.FloatField(),
),
), ),
is_members_ticket=(Q(restrict_to__isnull=False)), is_members_ticket=(Q(restrict_to__isnull=False)),
materials=Case( materials=Case(