Skip to content

Commit fc21fd8

Browse files
committed
Fixed the queryset filters using a proper reduce in the ConcurrencyActionMixin class, the previous code was not working when more than 1 object was selected in the list, also using a .count() on the queryset rather then len() for efficiency as we o not need the qs data, saxix#18
1 parent 044bcae commit fc21fd8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

concurrency/admin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## -*- coding: utf-8 -*-
22
from __future__ import absolute_import, unicode_literals
3+
import operator
34
import re
45
from django.utils.encoding import force_text
56
from django.contrib import admin, messages
@@ -96,8 +97,9 @@ def response_action(self, request, queryset):
9697
'expected: `%s` found' % x)
9798
filters.append(Q(**{'pk': pk,
9899
revision_field.attname: version}))
99-
queryset = queryset.filter(*filters)
100-
if len(selected) != len(queryset):
100+
101+
queryset = queryset.filter(reduce(operator.or_, filters))
102+
if len(selected) != queryset.count():
101103
messages.error(request, 'One or more record were updated. '
102104
'(Probably by other user) '
103105
'The execution was aborted.')

0 commit comments

Comments
 (0)