2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

feat: add action to remove all pending tasks (#9600)

This commit is contained in:
Matthias Mair
2025-05-01 20:19:27 +02:00
committed by GitHub
parent bd1fd9305d
commit 22b6dcd6cc
2 changed files with 49 additions and 2 deletions

View File

@ -422,10 +422,11 @@ class BulkOperationMixin:
items = request.data.pop('items', None)
filters = request.data.pop('filters', None)
all_filter = request.GET.get('all', None)
queryset = model.objects.all()
if not items and not filters:
if not items and not filters and all_filter is None:
raise ValidationError({
'non_field_errors': _(
'List of items or filters must be provided for bulk operation'
@ -459,6 +460,11 @@ class BulkOperationMixin:
'non_field_errors': _('Invalid filters provided')
})
if all_filter and not helpers.str2bool(all_filter):
raise ValidationError({
'non_field_errors': _('All filter must only be used with true')
})
if queryset.count() == 0:
raise ValidationError({
'non_field_errors': _('No items match the provided criteria')