forked from CGM_Public/pretix_original
Pluggable permissions (#5728)
* Data model draft * Refactor query and assignment usages of old permissions * Backend UI * API serializer * Big string replace * Docs, tests and fixes for teams api * Update docs for device auth * Eliminate old names * Make tests pass * Use new permissions, remove inconsistencies * Add test for translations * Show plugin permissions * Add permission for seating plans * Fix plugin activation * Fix failing test * Refactor to permission groups * Update doc/api/resources/devices.rst Co-authored-by: luelista <weller@rami.io> * Update doc/api/resources/events.rst Co-authored-by: luelista <weller@rami.io> * Update src/pretix/api/serializers/organizer.py Co-authored-by: luelista <weller@rami.io> * Fix typo * Fix python version compat * Replacement after rebase * Add proper permission handling for exports * Docs for exporters * Runtime linting of permission names * Fix typos * Show export page even without orders permission * More legacy compat * Do not strongly validate before plugins are loaded * Rebase migration * Add permission for outgoing mails * Review notes * Update doc/api/resources/teams.rst Co-authored-by: Richard Schreiber <schreiber@pretix.eu> * Clean up logic around exporters * Review and failures * Fix migration leading to forbidden combination * Handle permissions on event copying * Remove print-statements * Make test clearer * Review feedback * Add AnyPermissionOf * migration safety --------- Co-authored-by: luelista <weller@rami.io> Co-authored-by: Richard Schreiber <schreiber@pretix.eu>
This commit is contained in:
@@ -52,6 +52,7 @@ from pretix.helpers.models import modelcopy
|
||||
from pretix.plugins.badges.forms import BadgeLayoutForm
|
||||
from pretix.plugins.badges.tasks import badges_create_pdf
|
||||
|
||||
from ...base.permissions import AnyPermissionOf
|
||||
from ...helpers.compat import CompatDeleteView
|
||||
from .models import BadgeLayout
|
||||
from .templates import TEMPLATES
|
||||
@@ -59,7 +60,7 @@ from .templates import TEMPLATES
|
||||
|
||||
class LayoutListView(EventPermissionRequiredMixin, ListView):
|
||||
model = BadgeLayout
|
||||
permission = ('can_change_event_settings', 'can_view_orders')
|
||||
permission = AnyPermissionOf('event.settings.general:write', 'event.orders:read')
|
||||
template_name = 'pretixplugins/badges/index.html'
|
||||
context_object_name = 'layouts'
|
||||
|
||||
@@ -71,7 +72,7 @@ class LayoutCreate(EventPermissionRequiredMixin, CreateView):
|
||||
model = BadgeLayout
|
||||
form_class = BadgeLayoutForm
|
||||
template_name = 'pretixplugins/badges/edit.html'
|
||||
permission = 'can_change_event_settings'
|
||||
permission = 'event.settings.general:write'
|
||||
context_object_name = 'layout'
|
||||
success_url = '/ignored'
|
||||
|
||||
@@ -139,7 +140,7 @@ class LayoutCreate(EventPermissionRequiredMixin, CreateView):
|
||||
|
||||
class LayoutSetDefault(EventPermissionRequiredMixin, DetailView):
|
||||
model = BadgeLayout
|
||||
permission = 'can_change_event_settings'
|
||||
permission = 'event.settings.general:write'
|
||||
|
||||
def get_object(self, queryset=None) -> BadgeLayout:
|
||||
try:
|
||||
@@ -171,7 +172,7 @@ class LayoutSetDefault(EventPermissionRequiredMixin, DetailView):
|
||||
class LayoutDelete(EventPermissionRequiredMixin, CompatDeleteView):
|
||||
model = BadgeLayout
|
||||
template_name = 'pretixplugins/badges/delete.html'
|
||||
permission = 'can_change_event_settings'
|
||||
permission = 'event.settings.general:write'
|
||||
context_object_name = 'layout'
|
||||
|
||||
def get_object(self, queryset=None) -> BadgeLayout:
|
||||
@@ -269,7 +270,7 @@ class LayoutEditorView(BaseEditorView):
|
||||
|
||||
class OrderPrintDo(EventPermissionRequiredMixin, AsyncAction, View):
|
||||
task = badges_create_pdf
|
||||
permission = 'can_view_orders'
|
||||
permission = 'event.orders:read'
|
||||
known_errortypes = ['OrderError', 'ExportError']
|
||||
|
||||
def get_success_message(self, value):
|
||||
|
||||
Reference in New Issue
Block a user