mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Plugin settings: fixed problem with incompatible plugins
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
{% if plugin.app.compatibility_errors %}
|
{% if plugin.app.compatibility_errors %}
|
||||||
<button class="btn disabled btn-block btn-default">{% trans "Incompatible" %}</button>
|
<button class="btn disabled btn-block btn-default" disabled="disabled">{% trans "Incompatible" %}</button>
|
||||||
{% elif plugin.module in plugins_active %}
|
{% elif plugin.module in plugins_active %}
|
||||||
<button class="btn btn-default btn-block" name="plugin:{{ plugin.module }}" value="disable">{% trans "Disable" %}</button>
|
<button class="btn btn-default btn-block" name="plugin:{{ plugin.module }}" value="disable">{% trans "Disable" %}</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class EventPlugins(EventPermissionRequiredMixin, TemplateView, SingleObjectMixin
|
|||||||
|
|
||||||
context = super().get_context_data(*args, **kwargs)
|
context = super().get_context_data(*args, **kwargs)
|
||||||
context['plugins'] = [p for p in get_all_plugins() if not p.name.startswith('.')
|
context['plugins'] = [p for p in get_all_plugins() if not p.name.startswith('.')
|
||||||
if getattr(p, 'visible', True)]
|
and getattr(p, 'visible', True)]
|
||||||
context['plugins_active'] = self.object.get_plugins()
|
context['plugins_active'] = self.object.get_plugins()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -109,13 +109,21 @@ class EventPlugins(EventPermissionRequiredMixin, TemplateView, SingleObjectMixin
|
|||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
from pretix.base.plugins import get_all_plugins
|
||||||
|
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
|
|
||||||
plugins_active = self.object.get_plugins()
|
plugins_active = self.object.get_plugins()
|
||||||
|
plugins_available = {
|
||||||
|
p.module: p for p in get_all_plugins()
|
||||||
|
if not p.name.startswith('.') and getattr(p, 'visible', True)
|
||||||
|
}
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for key, value in request.POST.items():
|
for key, value in request.POST.items():
|
||||||
if key.startswith("plugin:"):
|
if key.startswith("plugin:"):
|
||||||
module = key.split(":")[1]
|
module = key.split(":")[1]
|
||||||
if value == "enable":
|
if value == "enable" and module in plugins_available:
|
||||||
self.request.event.log_action('pretix.event.plugins.enabled', user=self.request.user,
|
self.request.event.log_action('pretix.event.plugins.enabled', user=self.request.user,
|
||||||
data={'plugin': module})
|
data={'plugin': module})
|
||||||
if module not in plugins_active:
|
if module not in plugins_active:
|
||||||
|
|||||||
Reference in New Issue
Block a user