Move apple-developer-merchantid-domain-association into setting

This commit is contained in:
Martin Gross
2023-09-22 13:08:01 +02:00
parent 3ba36512d2
commit ca587108b4
7 changed files with 35 additions and 21 deletions
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
from django.http import Http404, HttpResponse
from pretix.base.settings import GlobalSettingsObject
def association(request, *args, **kwargs):
if hasattr(request, 'event'):
settings = request.event.settings
elif hasattr(request, 'organizer'):
settings = request.organizer.settings
else:
settings = GlobalSettingsObject().settings
if not settings.get('apple_domain_association', None):
raise Http404('')
else:
return HttpResponse(settings.get('apple_domain_association'))
@@ -38,6 +38,7 @@ from django import forms
from django.utils.translation import gettext_lazy as _
from i18nfield.forms import I18nFormField, I18nTextarea, I18nTextInput
from pretix import settings
from pretix.base.forms import SecretKeySettingsField, SettingsForm
from pretix.base.settings import GlobalSettingsObject
from pretix.base.signals import register_global_settings
@@ -95,6 +96,13 @@ class GlobalSettingsForm(SettingsForm):
sample='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
)
)),
('apple_domain_association', forms.CharField(
required=False,
label=_("ApplePay MerchantID Domain Association"),
help_text=_("Will be served at {domain}/.well-known/apple-developer-merchantid-domain-association").format(
domain=settings.SITE_URL
)
))
])
responses = register_global_settings.send(self)
for r, response in sorted(responses, key=lambda r: str(r[0])):
File diff suppressed because one or more lines are too long
+1 -11
View File
@@ -25,8 +25,7 @@ from pretix.multidomain import event_url
from .views import (
OrganizerSettingsFormView, ReturnView, ScaReturnView, ScaView,
applepay_association, oauth_disconnect, oauth_return, redirect_view,
webhook,
oauth_disconnect, oauth_return, redirect_view, webhook,
)
event_patterns = [
@@ -38,13 +37,6 @@ event_patterns = [
re_path(r'^sca/(?P<order>[^/]+)/(?P<hash>[^/]+)/(?P<payment>[0-9]+)/return/$',
ScaReturnView.as_view(), name='sca.return'),
])),
re_path(r'^.well-known/apple-developer-merchantid-domain-association$',
applepay_association, name='applepay.association'),
]
organizer_patterns = [
re_path(r'^.well-known/apple-developer-merchantid-domain-association$',
applepay_association, name='applepay.association'),
]
urlpatterns = [
@@ -54,6 +46,4 @@ urlpatterns = [
OrganizerSettingsFormView.as_view(), name='settings.connect'),
re_path(r'^_stripe/webhook/$', webhook, name='webhook'),
re_path(r'^_stripe/oauth_return/$', oauth_return, name='oauth.return'),
re_path(r'^.well-known/apple-developer-merchantid-domain-association$',
applepay_association, name='applepay.association'),
]
-7
View File
@@ -476,13 +476,6 @@ def oauth_disconnect(request, **kwargs):
}))
@xframe_options_exempt
def applepay_association(request, *args, **kwargs):
r = render(request, 'pretixplugins/stripe/apple-developer-merchantid-domain-association')
r._csp_ignore = True
return r
class StripeOrderView:
def dispatch(self, request, *args, **kwargs):
try:
+4 -2
View File
@@ -38,7 +38,7 @@ from django.views.generic import RedirectView
import pretix.control.urls
import pretix.presale.urls
from pretix.base.views import js_helpers
from pretix.base.views import js_helpers, applepay
from .base.views import (
cachedfiles, csp, health, js_catalog, metrics, redirect, source,
@@ -57,7 +57,9 @@ base_patterns = [
re_path(r'^agpl_source$', source.get_source, name='source'),
re_path(r'^js_helpers/states/$', js_helpers.states, name='js_helpers.states'),
re_path(r'^api/v1/', include(('pretix.api.urls', 'pretixapi'), namespace='api-v1')),
re_path(r'^api/$', RedirectView.as_view(url='/api/v1/'), name='redirect-api-version')
re_path(r'^api/$', RedirectView.as_view(url='/api/v1/'), name='redirect-api-version'),
re_path(r'^.well-known/apple-developer-merchantid-domain-association$',
applepay.association, name='applepay.association'),
]
control_patterns = [