Stripe checkout #104411
@ -4,7 +4,6 @@ import logging
|
|||||||
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.forms.utils import ErrorList
|
from django.forms.utils import ErrorList
|
||||||
from django.http import HttpResponse
|
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
from looper.models import Subscription
|
from looper.models import Subscription
|
||||||
@ -47,29 +46,6 @@ class SingleSubscriptionMixin(LoginRequiredMixin):
|
|||||||
'subscription': subscription,
|
'subscription': subscription,
|
||||||
}
|
}
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
|
||||||
"""Allow the view to do things that rely on auth state before dispatch.
|
|
||||||
|
|
||||||
The AnonymousUser instance doesn't have a 'subscriptions' property,
|
|
||||||
but login checking only happens in the super().dispatch() call.
|
|
||||||
"""
|
|
||||||
if not hasattr(request.user, 'customer'):
|
|
||||||
return self.handle_no_permission()
|
|
||||||
response = self.pre_dispatch(request, *args, **kwargs)
|
|
||||||
if response:
|
|
||||||
return response
|
|
||||||
return super().dispatch(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def pre_dispatch(self, request, *args, **kwargs) -> Optional[HttpResponse]:
|
|
||||||
"""Called between a permission check and calling super().dispatch().
|
|
||||||
|
|
||||||
This allows you to get the current subscription, or otherwise do things
|
|
||||||
that require the user to be logged in.
|
|
||||||
|
|
||||||
:return: None to continue handling this request, or a
|
|
||||||
HttpResponse to stop processing early.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class BootstrapErrorListMixin:
|
class BootstrapErrorListMixin:
|
||||||
"""Override get_form method changing error_class of the form."""
|
"""Override get_form method changing error_class of the form."""
|
||||||
|
Loading…
Reference in New Issue
Block a user