mirror of
https://github.com/pretix/pretix.git
synced 2026-10-02 19:24:42 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab294e120e | ||
|
|
d0f9608734 | ||
|
|
66d9944311 |
@@ -1198,7 +1198,7 @@ OrganizerFooterLinkFormset = inlineformset_factory(
|
||||
class SSOProviderForm(I18nModelForm):
|
||||
|
||||
config_oidc_base_url = forms.URLField(
|
||||
label=pgettext_lazy('sso_oidc', 'Base URL'),
|
||||
label=pgettext_lazy('sso_oidc', 'Base URL / issuer'),
|
||||
required=False,
|
||||
)
|
||||
config_oidc_client_id = forms.CharField(
|
||||
@@ -1295,6 +1295,14 @@ class SSOProviderForm(I18nModelForm):
|
||||
|
||||
|
||||
class SSOClientForm(I18nModelForm):
|
||||
disp_base_url = forms.CharField(
|
||||
label=_('Base URL / issuer'),
|
||||
disabled=True,
|
||||
)
|
||||
disp_client_id = forms.CharField(
|
||||
label=_('Client ID'),
|
||||
disabled=True,
|
||||
)
|
||||
regenerate_client_secret = forms.BooleanField(
|
||||
label=_('Invalidate old client secret and generate a new one'),
|
||||
required=False,
|
||||
@@ -1302,7 +1310,8 @@ class SSOClientForm(I18nModelForm):
|
||||
|
||||
class Meta:
|
||||
model = CustomerSSOClient
|
||||
fields = ['is_active', 'name', 'client_id', 'client_type', 'authorization_grant_type', 'redirect_uris',
|
||||
fields = ['is_active', 'name', 'disp_base_url', 'disp_client_id', 'regenerate_client_secret',
|
||||
'client_type', 'authorization_grant_type', 'redirect_uris',
|
||||
'allowed_scopes', 'require_pkce']
|
||||
widgets = {
|
||||
'authorization_grant_type': forms.RadioSelect,
|
||||
@@ -1317,13 +1326,15 @@ class SSOClientForm(I18nModelForm):
|
||||
help_text=self.fields['allowed_scopes'].help_text,
|
||||
required=self.fields['allowed_scopes'].required,
|
||||
initial=self.fields['allowed_scopes'].initial,
|
||||
choices=CustomerSSOClient.SCOPE_CHOICES,
|
||||
choices=[(val, format_html('<code>{}</code> – {}', val, label)) for val, label in CustomerSSOClient.SCOPE_CHOICES],
|
||||
widget=forms.CheckboxSelectMultiple
|
||||
)
|
||||
organizer = kwargs['event']
|
||||
self.initial['disp_base_url'] = eventreverse_absolute(organizer, 'presale:organizer.index', {}).strip('/')
|
||||
if self.instance and self.instance.pk:
|
||||
self.fields['client_id'].disabled = True
|
||||
self.initial['disp_client_id'] = self.instance.client_id
|
||||
else:
|
||||
del self.fields['client_id']
|
||||
self.initial['disp_client_id'] = _('(will be generated)')
|
||||
del self.fields['regenerate_client_secret']
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,29 @@
|
||||
{% extends "pretixcontrol/organizers/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% block title %}
|
||||
{% if client %}
|
||||
{% trans "SSO client:" %} {{ client.name }}
|
||||
{% else %}
|
||||
{% trans "Create credentials for a new SSO client" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block inner %}
|
||||
{% if client %}
|
||||
<h1>{% trans "SSO client:" %} {{ client.name }}</h1>
|
||||
{% else %}
|
||||
<h1>{% trans "Create a new SSO client" %}</h1>
|
||||
<h1>{% trans "Create credentials for a new SSO client" %}</h1>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
After submitting this form, client credentials for your SSO client will be generated.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
{% blocktrans trimmed with url="https://docs.pretix.eu/guides/customer-accounts/#using-pretix-as-an-sso-provider" %}
|
||||
For more information, refer to our documentation on <a href="{{ url }}">Using pretix as an SSO provider with external SSO clients</a>.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form layout="control" %}
|
||||
|
||||
@@ -3,16 +3,23 @@
|
||||
{% load bootstrap3 %}
|
||||
{% block title %}{% trans "SSO clients" %}{% endblock %}
|
||||
{% block inner %}
|
||||
<h1>{% trans "SSO clients" %}</h1>
|
||||
<h1>{% trans "SSO clients" %} <small> — {% blocktrans %}
|
||||
"Login with pretix" in external systems
|
||||
{% endblocktrans %}</small></h1>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
You can allow your customers to log into other systems using their customer account credentials by setting up
|
||||
your other systems as a Single-Sign-On (SSO) client based on OpenID Connect.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<p>
|
||||
{% blocktrans trimmed with url="https://docs.pretix.eu/guides/customer-accounts/#using-pretix-as-an-sso-provider" %}
|
||||
For more information, refer to our documentation on <a href="{{ url }}">Using pretix as an SSO provider with external SSO clients</a>.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<a href="{% url "control:organizer.ssoclient.add" organizer=request.organizer.slug %}" class="btn btn-default">
|
||||
<span class="fa fa-plus"></span>
|
||||
{% trans "Create a new SSO client" %}
|
||||
{% trans "Create credentials for a new SSO client" %}
|
||||
</a>
|
||||
<table class="table table-condensed table-hover">
|
||||
<thead>
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
{% extends "pretixcontrol/organizers/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% block title %}
|
||||
{% if provider %}
|
||||
{% trans "External SSO provider:" %} {{ provider.name }}
|
||||
{% else %}
|
||||
{% trans "Connect to an external SSO provider" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block inner %}
|
||||
{% if provider %}
|
||||
<h1>{% trans "SSO provider:" %} {{ provider.name }}</h1>
|
||||
<h1>{% trans "External SSO provider:" %} {{ provider.name }}</h1>
|
||||
{% else %}
|
||||
<h1>{% trans "Create a new SSO provider" %}</h1>
|
||||
<h1>{% trans "Connect to an external SSO provider" %}</h1>
|
||||
{% endif %}
|
||||
<p>
|
||||
{% blocktrans trimmed with url="https://docs.pretix.eu/guides/customer-accounts/#using-pretix-as-an-sso-client" %}
|
||||
For more information, refer to our documentation on <a href="{{ url }}" target="_blank">Using pretix as an SSO client</a>.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form layout="control" %}
|
||||
|
||||
@@ -3,16 +3,23 @@
|
||||
{% load bootstrap3 %}
|
||||
{% block title %}{% trans "SSO providers" %}{% endblock %}
|
||||
{% block inner %}
|
||||
<h1>{% trans "SSO providers" %}</h1>
|
||||
<h1>{% trans "SSO providers" %} <small> — {% blocktrans %}
|
||||
Connect to an external login provider
|
||||
{% endblocktrans %}</small></h1>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
You can connect existing Single-Sign-On (SSO) providers to allow your customers to log in using your own
|
||||
account system.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<p>
|
||||
{% blocktrans trimmed with url="https://docs.pretix.eu/guides/customer-accounts/#using-pretix-as-an-sso-client" %}
|
||||
For more information, refer to our documentation on <a href="{{ url }}" target="_blank">Using pretix as an SSO client</a>.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<a href="{% url "control:organizer.ssoprovider.add" organizer=request.organizer.slug %}" class="btn btn-default">
|
||||
<span class="fa fa-plus"></span>
|
||||
{% trans "Create a new SSO provider" %}
|
||||
{% trans "Connect to an external SSO provider" %}
|
||||
</a>
|
||||
<table class="table table-condensed table-hover">
|
||||
<thead>
|
||||
|
||||
@@ -2817,10 +2817,15 @@ class SSOProviderCreateView(OrganizerDetailViewMixin, OrganizerPermissionRequire
|
||||
return get_object_or_404(CustomerSSOProvider, organizer=self.request.organizer, pk=self.kwargs.get('provider'))
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('control:organizer.ssoproviders', kwargs={
|
||||
'organizer': self.request.organizer.slug,
|
||||
return reverse('control:organizer.ssoprovider.edit', kwargs={
|
||||
'organizer': self.request.organizer.slug, 'provider': self.object.pk,
|
||||
})
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['redirect_uri'] = _('(will be generated)')
|
||||
return ctx
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs['event'] = self.request.organizer
|
||||
@@ -2950,8 +2955,11 @@ class SSOClientCreateView(OrganizerDetailViewMixin, OrganizerPermissionRequiredM
|
||||
secret = form.instance.set_client_secret()
|
||||
messages.success(
|
||||
self.request,
|
||||
_('The SSO client has been created. Please note down the following client secret, it will never be shown '
|
||||
'again: {secret}').format(secret=secret)
|
||||
_('The SSO client has been created.') + ' ' +
|
||||
_('Please note down the following client secret, it will never be shown again.') + '\n\n' +
|
||||
_('Base URL / issuer') + f': {form.initial["disp_base_url"]}\n\n' +
|
||||
_('Client ID') + f': {form.instance.client_id}\n\n' +
|
||||
_('Client secret') + f': {secret}'
|
||||
)
|
||||
form.instance.organizer = self.request.organizer
|
||||
ret = super().form_valid(form)
|
||||
@@ -3000,8 +3008,9 @@ class SSOClientUpdateView(OrganizerDetailViewMixin, OrganizerPermissionRequiredM
|
||||
secret = form.instance.set_client_secret()
|
||||
messages.success(
|
||||
self.request,
|
||||
_('Your changes have been saved. Please note down the following client secret, it will never be shown '
|
||||
'again: {secret}').format(secret=secret)
|
||||
_('Your changes have been saved.') + ' ' +
|
||||
_('Please note down the following client secret, it will never be shown again.') + '\n\n' +
|
||||
_('Client secret') + f': {secret}'
|
||||
)
|
||||
else:
|
||||
messages.success(
|
||||
|
||||
@@ -40,6 +40,3 @@ class SendMailApp(AppConfig):
|
||||
def ready(self):
|
||||
from . import signals # NOQA
|
||||
from . import tasks # NOQA
|
||||
|
||||
def uninstalled(self, event):
|
||||
event.sendmail_rules.update(enabled=False)
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
from django.db import migrations
|
||||
from django.db.models import Exists, OuterRef
|
||||
|
||||
|
||||
def activate_plugin(apps, schema_editor):
|
||||
Event = apps.get_model("pretixbase", "Event")
|
||||
ScheduledMail = apps.get_model("sendmail", "ScheduledMail")
|
||||
Rule = apps.get_model("sendmail", "Rule")
|
||||
|
||||
events = (
|
||||
Event.objects
|
||||
.exclude(plugins__icontains="pretix.plugins.sendmail")
|
||||
.filter(
|
||||
Exists(
|
||||
ScheduledMail.objects.filter(event=OuterRef('pk'), rule__enabled=True).exclude(
|
||||
state__in=['completed', 'missed'])
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
for event in events:
|
||||
event.enable_plugin('pretix.plugins.sendmail')
|
||||
event.save(update_fields=['plugins'])
|
||||
|
||||
only_completed_rules = Rule.objects.exclude(event__plugins__icontains="pretix.plugins.sendmail",
|
||||
enabled=False).filter(
|
||||
~Exists(ScheduledMail.objects.filter(rule=OuterRef('pk')).exclude(state__in=['completed', 'missed']))
|
||||
)
|
||||
only_completed_rules.update(enabled=False)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("sendmail", "0012_remove_cross_event_scheduled_mails"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(activate_plugin),
|
||||
]
|
||||
@@ -181,7 +181,6 @@ def sendmail_run_rules(sender, **kwargs):
|
||||
state=ScheduledMail.STATE_MISSED
|
||||
)
|
||||
for m_id in mails.filter(
|
||||
event__plugins__contains="pretix.plugins.sendmail",
|
||||
state__in=(ScheduledMail.STATE_SCHEDULED, ScheduledMail.STATE_FAILED),
|
||||
rule__enabled=True,
|
||||
event__live=True,
|
||||
|
||||
Reference in New Issue
Block a user