Stripe checkout #104411

Merged
Anna Sirota merged 61 commits from stripe into main 2024-06-17 18:08:41 +02:00
Showing only changes of commit ac08acae00 - Show all commits

View File

@ -4,7 +4,6 @@ import logging
from django.contrib.auth.mixins import LoginRequiredMixin
from django.forms.utils import ErrorList
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from looper.models import Subscription
@ -47,29 +46,6 @@ class SingleSubscriptionMixin(LoginRequiredMixin):
'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:
"""Override get_form method changing error_class of the form."""