mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Restrict Payment Providers to Sales Channels (#1481)
* Allow to restrict payment providers to specific sales channels * Fix test * Add `payment_restrictions_supported`-property to SalesChannels
This commit is contained in:
committed by
Raphael Michel
parent
384e7f8fc1
commit
6896682dd1
@@ -719,7 +719,7 @@ class ProviderForm(SettingsForm):
|
||||
v.set_event(self.obj)
|
||||
|
||||
if hasattr(v, '_as_type'):
|
||||
self.initial[k] = self.obj.settings.get(k, as_type=v._as_type)
|
||||
self.initial[k] = self.obj.settings.get(k, as_type=v._as_type, default=v.initial)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
|
||||
@@ -28,6 +28,12 @@
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="iconcol">
|
||||
{% for channel in provider.sales_channels %}
|
||||
<span class="fa fa-{{ channel.icon }} text-muted"
|
||||
data-toggle="tooltip" title="{% trans channel.verbose_name %}"></span>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td class="text-right flip">
|
||||
<a href="{% url 'control:event.settings.payment.provider' event=request.event.slug organizer=request.organizer.slug provider=provider.identifier %}"
|
||||
class="btn btn-default">
|
||||
|
||||
@@ -392,11 +392,15 @@ class PaymentSettings(EventSettingsViewMixin, EventSettingsFormView):
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context['providers'] = sorted(
|
||||
[p for p in self.request.event.get_payment_providers().values()
|
||||
if not p.is_implicit and (p.settings_form_fields or p.settings_content_render(self.request))],
|
||||
if not (p.is_implicit(self.request) if callable(p.is_implicit) else p.is_implicit) and
|
||||
(p.settings_form_fields or p.settings_content_render(self.request))],
|
||||
key=lambda s: s.verbose_name
|
||||
)
|
||||
|
||||
sales_channels = get_all_sales_channels()
|
||||
for p in context['providers']:
|
||||
p.show_enabled = p.is_enabled
|
||||
p.sales_channels = [sales_channels[channel] for channel in p.settings.get('_restrict_to_sales_channels', as_type=list, default=['web'])]
|
||||
if p.is_meta:
|
||||
p.show_enabled = p.settings._enabled in (True, 'True')
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user