Configure PayPal integration and cart checkout error display
This commit is contained in:
1 parent
62065828e1
commit
cf07fc5d9b
98 files changed
+1430
-281
No files matched your search
@@ -21,14 +21,14 @@ RANKS = (
|
||||
)
|
||||
|
||||
|
||||
def rank_for(membership, total, config, now):
|
||||
def rank_for(membership, total, config, now, stripe_active=False):
|
||||
if (membership and membership.sol_seat) or (config.seat_threshold is not None and total >= config.seat_threshold):
|
||||
return RANKS[4]
|
||||
if total >= config.striker_threshold:
|
||||
return RANKS[3]
|
||||
if total >= config.caster_threshold:
|
||||
return RANKS[2]
|
||||
if membership and membership.subscriber_until and membership.subscriber_until > now:
|
||||
if stripe_active or (membership and membership.subscriber_until and membership.subscriber_until > now):
|
||||
return RANKS[1]
|
||||
return RANKS[0]
|
||||
|
||||
@@ -41,4 +41,9 @@ def load_ranks(ids, config):
|
||||
sums = dict(SupportCredit.objects.filter(user_id__in=ids, voided=False).values('user_id')
|
||||
.annotate(total=Sum('amount')).values_list('user_id', 'total'))
|
||||
now = timezone.now()
|
||||
return {pk: rank_for(memberships.get(pk), sums.get(pk, Decimal(0)), config, now) for pk in ids}
|
||||
from .chapter_access import stripe_live_mode
|
||||
from shop.models import Order, Subscription
|
||||
active = set(Subscription.objects.filter(user_id__in=ids, gateway=Order.Gateway.STRIPE,
|
||||
stripe_live=stripe_live_mode(), status=Subscription.Status.ACTIVE, current_period_end__gt=now,
|
||||
entitlement_tier__isnull=False).values_list('user_id', flat=True))
|
||||
return {pk: rank_for(memberships.get(pk), sums.get(pk, Decimal(0)), config, now, pk in active) for pk in ids}
|
||||
Reference in new issue
Block a user