From d3f41ff13b1eff70c204c9638090714a34e71936 Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Mon, 30 Jan 2023 21:20:02 -0700 Subject: [PATCH] Fix bug when user arrives at SubscriptionCreateView to reroute if no subscription --- storefront/views.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storefront/views.py b/storefront/views.py index 174a4e9..03152dc 100644 --- a/storefront/views.py +++ b/storefront/views.py @@ -626,6 +626,11 @@ class SubscriptionCreateView(SuccessMessageMixin, CreateView): template_name = 'storefront/subscription/create_form.html' fields = [] + def get(self, request, *args, **kwargs): + if not self.request.session.get('subscription'): + return HttpResponseRedirect(reverse('storefront:subscription-form')) + return super().get(request, *args, **kwargs) + def get_item_list(self): item_list = [{ 'product': Product.objects.get(pk=item['pk']),