Stripe checkout #104411
@ -78,9 +78,6 @@ def _set_order_number(sender, instance: Order, **kwargs):
|
|||||||
def _on_subscription_created_needs_payment(sender: looper.models.Subscription, **kwargs):
|
def _on_subscription_created_needs_payment(sender: looper.models.Subscription, **kwargs):
|
||||||
tasks.send_mail_bank_transfer_required(subscription_id=sender.pk)
|
tasks.send_mail_bank_transfer_required(subscription_id=sender.pk)
|
||||||
user = sender.customer.user
|
user = sender.customer.user
|
||||||
if not user:
|
|
||||||
logger.error('Cannot grant role to an account-less customer pk=%s', sender.customer_id)
|
|
||||||
return
|
|
||||||
users.tasks.grant_blender_id_role(pk=user.pk, role='cloud_has_subscription')
|
users.tasks.grant_blender_id_role(pk=user.pk, role='cloud_has_subscription')
|
||||||
|
|
||||||
|
|
||||||
@ -93,9 +90,6 @@ def _on_subscription_status_changed(sender: looper.models.Subscription, **kwargs
|
|||||||
@receiver(looper.signals.subscription_activated)
|
@receiver(looper.signals.subscription_activated)
|
||||||
def _on_subscription_status_activated(sender: looper.models.Subscription, **kwargs):
|
def _on_subscription_status_activated(sender: looper.models.Subscription, **kwargs):
|
||||||
user = sender.customer.user
|
user = sender.customer.user
|
||||||
if not user:
|
|
||||||
logger.error('Cannot grant role to an account-less customer pk=%s', sender.customer_id)
|
|
||||||
return
|
|
||||||
users.tasks.grant_blender_id_role(pk=user.pk, role='cloud_has_subscription')
|
users.tasks.grant_blender_id_role(pk=user.pk, role='cloud_has_subscription')
|
||||||
users.tasks.grant_blender_id_role(pk=user.pk, role='cloud_subscriber')
|
users.tasks.grant_blender_id_role(pk=user.pk, role='cloud_subscriber')
|
||||||
|
|
||||||
@ -111,7 +105,7 @@ def _on_subscription_status_activated(sender: looper.models.Subscription, **kwar
|
|||||||
def _on_subscription_status_deactivated(sender: looper.models.Subscription, **kwargs):
|
def _on_subscription_status_deactivated(sender: looper.models.Subscription, **kwargs):
|
||||||
# No other active subscription exists, subscriber badge can be revoked
|
# No other active subscription exists, subscriber badge can be revoked
|
||||||
user = sender.customer.user
|
user = sender.customer.user
|
||||||
if user and not queries.has_active_subscription(user):
|
if not queries.has_active_subscription(user):
|
||||||
users.tasks.revoke_blender_id_role(pk=user.pk, role='cloud_subscriber')
|
users.tasks.revoke_blender_id_role(pk=user.pk, role='cloud_subscriber')
|
||||||
|
|
||||||
if not hasattr(sender, 'team'):
|
if not hasattr(sender, 'team'):
|
||||||
@ -151,7 +145,7 @@ def _on_subscription_expired(sender: looper.models.Subscription, **kwargs):
|
|||||||
|
|
||||||
# Only send a "subscription expired" email when there are no other active subscriptions
|
# Only send a "subscription expired" email when there are no other active subscriptions
|
||||||
user = sender.customer.user
|
user = sender.customer.user
|
||||||
if user and not queries.has_active_subscription(user):
|
if not queries.has_active_subscription(user):
|
||||||
tasks.send_mail_subscription_expired(subscription_id=sender.pk)
|
tasks.send_mail_subscription_expired(subscription_id=sender.pk)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user