Skip to content

Commit 01f7b57

Browse files
committed
Merge branch 'develop' of github.com:saxix/django-concurrency into develop
* 'develop' of github.com:saxix/django-concurrency: fixes admin action bug occurring when setting `select all` checkbox (`select_across`)
2 parents 71a3f26 + 4ff077d commit 01f7b57

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/concurrency/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def response_action(self, request, queryset): # noqa
8585

8686
# Get the list of selected PKs. If nothing's selected, we can't
8787
# perform an action on it, so bail.
88-
if int(request.POST.get('select_across', 0)):
88+
if action_form.cleaned_data['select_across']:
8989
selected = ALL
9090
else:
9191
selected = request.POST.getlist(helpers.ACTION_CHECKBOX_NAME)

tests/test_admin_actions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ def test_dummy_action(self):
3333
self.assertIn('**concurrent_update**', res)
3434
self.assertNotIn('**action_update**', res)
3535

36+
def test_dummy_action_select_across(self):
37+
id = next(unique_id)
38+
SimpleConcurrentModel.objects.get_or_create(pk=id)
39+
res = self.app.get('/admin/', user='sax')
40+
41+
res = res.click('^SimpleConcurrentModels')
42+
assert 'SimpleConcurrentModel #%s' % id in res # sanity check
43+
44+
self._create_conflict(id)
45+
46+
form = res.forms['changelist-form']
47+
form['action'].value = 'dummy_action'
48+
form['select_across'] = 'True'
49+
sel = form.get('_selected_action', index=0) # needed
50+
sel.checked = True # needed
51+
res = form.submit()
52+
res = res.follow()
53+
54+
self.assertIn('Selecting all records, you will avoid the concurrency check', res)
55+
3656
@pytest.mark.skipif(django.VERSION[:2] >= (1, 7), reason="Skip django>=1.9")
3757
def test_delete_allowed_if_no_updates(self):
3858
id = next(unique_id)

0 commit comments

Comments
 (0)