forked from CGM_Public/pretix_original
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:
@@ -53,7 +53,6 @@ from django.utils.timezone import now
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_otp.models import Device
|
||||
from django_scopes import scopes_disabled
|
||||
from webauthn.helpers.structs import PublicKeyCredentialDescriptor
|
||||
|
||||
from pretix.base.i18n import language
|
||||
from pretix.helpers.urls import build_absolute_uri
|
||||
@@ -708,6 +707,8 @@ class U2FDevice(Device):
|
||||
|
||||
@property
|
||||
def webauthndevice(self):
|
||||
from webauthn.helpers.structs import PublicKeyCredentialDescriptor
|
||||
|
||||
d = json.loads(self.json_data)
|
||||
return PublicKeyCredentialDescriptor(websafe_decode(d['keyHandle']))
|
||||
|
||||
@@ -737,6 +738,8 @@ class WebAuthnDevice(Device):
|
||||
|
||||
@property
|
||||
def webauthndevice(self):
|
||||
from webauthn.helpers.structs import PublicKeyCredentialDescriptor
|
||||
|
||||
return PublicKeyCredentialDescriptor(websafe_decode(self.credential_id))
|
||||
|
||||
@property
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
import json
|
||||
from collections import namedtuple
|
||||
|
||||
import jsonschema
|
||||
from django.contrib.staticfiles import finders
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
@@ -38,6 +37,8 @@ from pretix.base.models import Event, Item, LoggedModel, Organizer, SubEvent
|
||||
@deconstructible
|
||||
class SeatingPlanLayoutValidator:
|
||||
def __call__(self, value):
|
||||
import jsonschema
|
||||
|
||||
if not isinstance(value, dict):
|
||||
try:
|
||||
val = json.loads(value)
|
||||
|
||||
@@ -23,7 +23,6 @@ import json
|
||||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
|
||||
import jsonschema
|
||||
from django.contrib.staticfiles import finders
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
@@ -298,6 +297,8 @@ def cc_to_vat_prefix(country_code):
|
||||
@deconstructible
|
||||
class CustomRulesValidator:
|
||||
def __call__(self, value):
|
||||
import jsonschema
|
||||
|
||||
if not isinstance(value, dict):
|
||||
try:
|
||||
val = json.loads(value)
|
||||
|
||||
@@ -47,7 +47,6 @@ from collections import OrderedDict, defaultdict
|
||||
from functools import partial
|
||||
from io import BytesIO
|
||||
|
||||
import jsonschema
|
||||
import pypdf
|
||||
import pypdf.generic
|
||||
import reportlab.rl_config
|
||||
@@ -1311,6 +1310,8 @@ def _correct_page_media_box(page: pypdf.PageObject):
|
||||
@deconstructible
|
||||
class PdfLayoutValidator:
|
||||
def __call__(self, value):
|
||||
import jsonschema
|
||||
|
||||
if not isinstance(value, dict):
|
||||
try:
|
||||
val = json.loads(value)
|
||||
|
||||
@@ -47,7 +47,6 @@ from urllib.parse import urljoin, urlparse
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from celery import chain
|
||||
from celery.exceptions import MaxRetriesExceededError
|
||||
from django.conf import settings
|
||||
@@ -764,6 +763,8 @@ def render_mail(template, context, placeholder_mode=SafeFormatter.MODE_RICH_TO_P
|
||||
|
||||
|
||||
def replace_images_with_cid_paths(body_html):
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
if body_html:
|
||||
email = BeautifulSoup(body_html, "lxml")
|
||||
cid_images = []
|
||||
|
||||
Reference in New Issue
Block a user