mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Change restricted plugins from event-level action to org-level whitelist (#2489)
This commit is contained in:
@@ -94,6 +94,25 @@ def primary_font_kwargs():
|
||||
}
|
||||
|
||||
|
||||
def restricted_plugin_kwargs():
|
||||
from pretix.base.plugins import get_all_plugins
|
||||
|
||||
plugins_available = [
|
||||
(p.module, p.name) for p in get_all_plugins(None)
|
||||
if (
|
||||
not p.name.startswith('.') and
|
||||
getattr(p, 'visible', True) and
|
||||
getattr(p, 'restricted', False) and
|
||||
not hasattr(p, 'is_available') # this means you should not really use restricted and is_available
|
||||
)
|
||||
]
|
||||
return {
|
||||
'widget': forms.CheckboxSelectMultiple,
|
||||
'label': _("Allow usage of restricted plugins"),
|
||||
'choices': plugins_available,
|
||||
}
|
||||
|
||||
|
||||
class LazyI18nStringList(UserList):
|
||||
def __init__(self, init_list=None):
|
||||
super().__init__()
|
||||
@@ -109,6 +128,13 @@ class LazyI18nStringList(UserList):
|
||||
|
||||
|
||||
DEFAULTS = {
|
||||
'allowed_restricted_plugins': {
|
||||
'default': [],
|
||||
'type': list,
|
||||
'form_class': forms.MultipleChoiceField,
|
||||
'serializer_class': serializers.MultipleChoiceField,
|
||||
'form_kwargs': lambda: restricted_plugin_kwargs(),
|
||||
},
|
||||
'customer_accounts': {
|
||||
'default': 'False',
|
||||
'type': bool,
|
||||
|
||||
Reference in New Issue
Block a user