Commit cc0d1022 authored by David Seaward's avatar David Seaward
Browse files

Contain subscription-related errors.


Signed-off-by: David Seaward's avatarDavid Seaward <david.seaward@puri.sm>
parent aafed233
Pipeline #54238 passed with stage
in 31 seconds
...@@ -10,6 +10,9 @@ from .forms import CartRegistrationFormWithCaptcha, CartRegistrationForm ...@@ -10,6 +10,9 @@ from .forms import CartRegistrationFormWithCaptcha, CartRegistrationForm
from limitmonitor.common import forced_update from limitmonitor.common import forced_update
from limitmonitor.subscription import SubscriptionManager, SubscriptionStatus from limitmonitor.subscription import SubscriptionManager, SubscriptionStatus
import json import json
import logging
log = logging.getLogger(__name__)
class CartRegistrationView(RegistrationView): class CartRegistrationView(RegistrationView):
...@@ -77,15 +80,22 @@ class CartRegistrationView(RegistrationView): ...@@ -77,15 +80,22 @@ class CartRegistrationView(RegistrationView):
if self.bundle == 'Basic': if self.bundle == 'Basic':
user.account_type = AccountType.BASIC user.account_type = AccountType.BASIC
user.save()
reward.save() try:
new_sub = SubscriptionManager.create_subscription( new_sub = SubscriptionManager.create_subscription(
user, paid=True, user, paid=True,
status=SubscriptionStatus.ACTIVE, status=SubscriptionStatus.ACTIVE,
billing_email=user.email billing_email=user.email
) )
assert new_sub is not None, "Failed to create subscription for {}".format(user)
forced_update(user) if new_sub is None:
raise Exception("Subscription is None.")
forced_update(user)
except Exception as e:
message = "Failed to create subscription for basic user {}.".format(user)
logging.exception(message)
elif self.bundle == 'Complete': elif self.bundle == 'Complete':
user.account_type = AccountType.COMPLETE user.account_type = AccountType.COMPLETE
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment