forked from CGM_Public/pretix_original
Make plugin dependencies optional by allowing plugins to report errors
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from pretix.base.plugins import PluginType
|
||||
|
||||
@@ -18,5 +19,14 @@ class StripeApp(AppConfig):
|
||||
def ready(self):
|
||||
from . import signals # NOQA
|
||||
|
||||
@cached_property
|
||||
def compatibility_errors(self):
|
||||
errs = []
|
||||
try:
|
||||
import stripe
|
||||
except ImportError:
|
||||
errs.append("Python package 'stripe' is not installed.")
|
||||
return errs
|
||||
|
||||
|
||||
default_app_config = 'pretix.plugins.stripe.StripeApp'
|
||||
|
||||
@@ -5,17 +5,18 @@ from django.template.loader import get_template
|
||||
|
||||
from pretix.base.signals import register_payment_providers
|
||||
|
||||
from .payment import Stripe
|
||||
from pretix.presale.signals import html_head
|
||||
|
||||
|
||||
@receiver(register_payment_providers)
|
||||
def register_payment_provider(sender, **kwargs):
|
||||
from .payment import Stripe
|
||||
return Stripe
|
||||
|
||||
|
||||
@receiver(html_head)
|
||||
def html_head_presale(sender, request=None, **kwargs):
|
||||
from .payment import Stripe
|
||||
provider = Stripe(sender)
|
||||
url = resolve(request.path_info)
|
||||
if provider.is_enabled and "checkout.payment" in url.url_name:
|
||||
|
||||
Reference in New Issue
Block a user