kopia lustrzana https://github.com/wagtail/wagtail
Add permission check
rodzic
186a9fc128
commit
28e68f3882
|
@ -2,6 +2,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
from django.utils.translation import ngettext
|
||||
|
||||
from wagtail.contrib.forms.bulk_actions.form_bulk_action import FormSubmissionBulkAction
|
||||
from wagtail.contrib.forms.utils import get_forms_for_user
|
||||
|
||||
|
||||
class DeleteBulkAction(FormSubmissionBulkAction):
|
||||
|
@ -10,6 +11,9 @@ class DeleteBulkAction(FormSubmissionBulkAction):
|
|||
action_type = "delete"
|
||||
template_name = "bulk_actions/confirm_bulk_delete.html"
|
||||
|
||||
def check_perm(self, obj):
|
||||
return get_forms_for_user(self.request.user).exists()
|
||||
|
||||
@classmethod
|
||||
def execute_action(cls, objects, **kwargs):
|
||||
num_forms = 0
|
||||
|
@ -25,4 +29,4 @@ class DeleteBulkAction(FormSubmissionBulkAction):
|
|||
"One submission has been deleted.",
|
||||
"%(count)d submissions have been deleted.",
|
||||
count,
|
||||
) % {"count": count}
|
||||
) % {"count": count}
|
||||
|
|
Ładowanie…
Reference in New Issue