Commit 4506e28a authored by Birin Sanchez's avatar Birin Sanchez
Browse files

Handle SubscriptionParseError in UpgradeView and

Signed-off-by: Birin Sanchez's avatarBirin Sanchez <>
parent c9bac670
Pipeline #18642 passed with stage
in 30 seconds
......@@ -6,7 +6,7 @@ from .forms import ChooseBundleForm
from .models import BundleChange
from limitmonitor.common import get_user_subscriptions, parse_subscription, \
set_subscription_status, get_user_external_credit, get_available_bundles, \
get_user_upgrade_choices, SubscriptionParseError
from limitmonitor.task_resources.subscription import upgrade_user_subscription
......@@ -60,9 +60,14 @@ class UpgradeView(LoginRequiredMixin, FormView):
variation_id = form.cleaned_data['bundle']
subs = get_user_subscriptions(self.request.user)
# We assume the user has only 1 subscription!
# We assume the user has only 1 active subscription!
if subs:
parsed_sub = parse_subscription(subs[0])
parsed_sub = parse_subscription(subs[0])
except SubscriptionParseError as e:
print('Error processing bundle_change for user {}: {}'.format(
self.request.user, repr(e)))
return super(UpgradeView, self).form_valid(form)
order = upgrade_user_subscription(self.request.user,
pay_url = settings.WOO_UPGRADE_PAY_URL.format(order['id'],
......@@ -4,7 +4,8 @@ from cart.models import ChosenReward
from bundlechange.models import BundleChange
from limitmonitor.common import parse_subscription, get_user_subscriptions, \
subscription_was_processed, get_services_from_bundle, forced_update, \
get_users_expired_subs, order_paid, set_subscription_status
get_users_expired_subs, order_paid, set_subscription_status, \
logger = get_task_logger(__name__)
......@@ -17,7 +18,11 @@ def process_pending_registrations_user(user):'User {} has no subscriptions.'.format(user.username))
for sub in subscriptions:
parsed_sub = parse_subscription(sub)
parsed_sub = parse_subscription(sub)
except SubscriptionParseError as parse_e:
if parsed_sub['bundle_key'] not in settings.WOOSUB1_PRODUCT_LIST:
continue # Skip this subscription as is not a product we care of
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