From a2f2d2516917a42d6af931948e2ac25e45f2a8db Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 4 Jan 2023 18:12:58 +0100 Subject: [PATCH] Allow users with can_checkin_orders permission to use the bulk actions of the check-in list view --- src/pretix/base/views/tasks.py | 8 +++++--- .../pretixcontrol/checkin/index.html | 12 +++++++---- src/pretix/control/views/checkin.py | 8 +++++++- src/tests/control/test_checkins.py | 20 +++++++++++++++++++ src/tests/control/test_permissions.py | 1 + 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/pretix/base/views/tasks.py b/src/pretix/base/views/tasks.py index 89c12819f6..6302b33740 100644 --- a/src/pretix/base/views/tasks.py +++ b/src/pretix/base/views/tasks.py @@ -28,7 +28,7 @@ from celery import states from celery.result import AsyncResult from django.conf import settings from django.contrib import messages -from django.core.exceptions import ValidationError +from django.core.exceptions import PermissionDenied, ValidationError from django.http import HttpResponse, JsonResponse, QueryDict from django.shortcuts import redirect, render from django.test import RequestFactory @@ -149,6 +149,8 @@ class AsyncMixin: return redirect(self.get_success_url(value)) def error(self, exception): + if isinstance(exception, PermissionDenied): + raise exception messages.error(self.request, self.get_error_message(exception)) if "ajax" in self.request.POST or "ajax" in self.request.GET: return JsonResponse({ @@ -337,8 +339,8 @@ class AsyncPostView(AsyncMixin, View): depend on the request object unless specifically supported by this class. File upload is currently also not supported. """ - known_errortypes = ['ValidationError'] - expected_exceptions = (ValidationError,) + known_errortypes = ['ValidationError', 'PermissionDenied'] + expected_exceptions = (ValidationError, PermissionDenied) task_base = ProfiledEventTask def async_set_progress(self, percentage): diff --git a/src/pretix/control/templates/pretixcontrol/checkin/index.html b/src/pretix/control/templates/pretixcontrol/checkin/index.html index 63d6ef332d..2fc3c1fb7c 100644 --- a/src/pretix/control/templates/pretixcontrol/checkin/index.html +++ b/src/pretix/control/templates/pretixcontrol/checkin/index.html @@ -82,8 +82,10 @@ - + {% if "can_change_orders" in request.eventpermset or "can_checkin_orders" in request.eventpermset %} + + {% endif %} {% trans "Order code" %} @@ -125,7 +127,7 @@ {% for e in entries %} - {% if "can_change_orders" in request.eventpermset %} + {% if "can_change_orders" in request.eventpermset or "can_checkin_orders" in request.eventpermset %} {% endif %} @@ -198,7 +200,7 @@ - {% if "can_change_orders" in request.eventpermset %} + {% if "can_change_orders" in request.eventpermset or "can_checkin_orders" in request.eventpermset %} + {% endif %} + {% if "can_change_orders" in request.eventpermset %}