mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Import large package lazily to speed up startup (#5636)
* Import large package lazily to speed up startup * Make all jsonschema imports lazy
This commit is contained in:
@@ -38,7 +38,6 @@ from pretix.base.signals import (
|
||||
)
|
||||
from pretix.control.signals import nav_organizer
|
||||
from pretix.plugins.stripe.forms import StripeKeyValidator
|
||||
from pretix.plugins.stripe.payment import StripeMethod
|
||||
from pretix.presale.signals import html_head, process_response
|
||||
|
||||
|
||||
@@ -189,6 +188,8 @@ def nav_o(sender, request, organizer, **kwargs):
|
||||
|
||||
@receiver(signal=process_response, dispatch_uid="stripe_middleware_resp")
|
||||
def signal_process_response(sender, request: HttpRequest, response: HttpResponse, **kwargs):
|
||||
from pretix.plugins.stripe.payment import StripeMethod
|
||||
|
||||
provider = StripeMethod(sender)
|
||||
url = resolve(request.path_info)
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
import logging
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
import stripe
|
||||
from django.conf import settings
|
||||
|
||||
from pretix.base.services.tasks import EventTask
|
||||
@@ -50,7 +49,10 @@ def get_stripe_account_key(prov):
|
||||
|
||||
@app.task(base=EventTask, max_retries=5, default_retry_delay=1)
|
||||
def stripe_verify_domain(event, domain):
|
||||
import stripe
|
||||
|
||||
from pretix.plugins.stripe.payment import StripeCC
|
||||
|
||||
prov = StripeCC(event)
|
||||
account = get_stripe_account_key(prov)
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import logging
|
||||
import urllib.parse
|
||||
|
||||
import requests
|
||||
import stripe
|
||||
from django.contrib import messages
|
||||
from django.core import signing
|
||||
from django.db import transaction
|
||||
@@ -68,7 +67,6 @@ from pretix.helpers.http import redirect_to_url
|
||||
from pretix.multidomain.urlreverse import build_absolute_uri, eventreverse
|
||||
from pretix.plugins.stripe.forms import OrganizerStripeSettingsForm
|
||||
from pretix.plugins.stripe.models import ReferencedStripeObject
|
||||
from pretix.plugins.stripe.payment import StripeCC, StripeSettingsHolder
|
||||
from pretix.plugins.stripe.tasks import (
|
||||
get_domain_for_event, stripe_verify_domain,
|
||||
)
|
||||
@@ -100,6 +98,8 @@ def redirect_view(request, *args, **kwargs):
|
||||
|
||||
@scopes_disabled()
|
||||
def oauth_return(request, *args, **kwargs):
|
||||
import stripe
|
||||
|
||||
if 'payment_stripe_oauth_event' not in request.session:
|
||||
messages.error(request, _('An error occurred during connecting with Stripe, please try again.'))
|
||||
return redirect('control:index')
|
||||
@@ -268,6 +268,10 @@ SOURCE_TYPES = {
|
||||
|
||||
|
||||
def charge_webhook(event, event_json, charge_id, rso):
|
||||
import stripe
|
||||
|
||||
from pretix.plugins.stripe.payment import StripeCC
|
||||
|
||||
prov = StripeCC(event)
|
||||
prov._init_api()
|
||||
|
||||
@@ -371,6 +375,10 @@ def charge_webhook(event, event_json, charge_id, rso):
|
||||
|
||||
|
||||
def source_webhook(event, event_json, source_id, rso):
|
||||
import stripe
|
||||
|
||||
from pretix.plugins.stripe.payment import StripeCC
|
||||
|
||||
prov = StripeCC(event)
|
||||
prov._init_api()
|
||||
try:
|
||||
@@ -440,6 +448,10 @@ def source_webhook(event, event_json, source_id, rso):
|
||||
|
||||
|
||||
def paymentintent_webhook(event, event_json, paymentintent_id, rso):
|
||||
import stripe
|
||||
|
||||
from pretix.plugins.stripe.payment import StripeCC
|
||||
|
||||
prov = StripeCC(event)
|
||||
prov._init_api()
|
||||
|
||||
@@ -516,6 +528,8 @@ class StripeOrderView:
|
||||
@method_decorator(xframe_options_exempt, 'dispatch')
|
||||
class ReturnView(StripeOrderView, View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
import stripe
|
||||
|
||||
prov = self.pprov
|
||||
prov._init_api()
|
||||
try:
|
||||
@@ -568,6 +582,10 @@ class ReturnView(StripeOrderView, View):
|
||||
class ScaView(StripeOrderView, View):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
import stripe
|
||||
|
||||
from pretix.plugins.stripe.payment import StripeSettingsHolder
|
||||
|
||||
prov = self.pprov
|
||||
prov._init_api()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user