Skip to content

Commit 2bc83c0

Browse files
committed
Merge pull request #63 from Haos616/develop
Changed view errors for ConcurrencyListEditableMixin
2 parents 9918d10 + f730571 commit 2bc83c0

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/concurrency/admin.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,19 @@ def message_user(self, request, message, *args, **kwargs):
224224
concurrency_errros = len(conflicts)
225225
if m:
226226
updated_record = int(m.group('num')) - concurrency_errros
227-
if updated_record == 0:
228-
message = _("No %(name)s were changed due conflict errors") % {'name': names[0]}
227+
228+
ids = ",".join(map(str, conflicts))
229+
messages.error(request,
230+
ungettext("Record with pk `{0}` has been modified and was not updated",
231+
"Records `{0}` have been modified and were not updated",
232+
concurrency_errros).format(ids))
233+
if updated_record == 1:
234+
name = force_text(opts.verbose_name)
229235
else:
230-
ids = ",".join(map(str, conflicts))
231-
messages.error(request,
232-
ungettext("Record with pk `{0}` has been modified and was not updated",
233-
"Records `{0}` have been modified and were not updated",
234-
concurrency_errros).format(ids))
235-
if updated_record == 1:
236-
name = force_text(opts.verbose_name)
237-
else:
238-
name = force_text(opts.verbose_name_plural)
236+
name = force_text(opts.verbose_name_plural)
237+
238+
message = None
239+
if updated_record > 0:
239240
message = ungettext("%(count)s %(name)s was changed successfully.",
240241
"%(count)s %(name)s were changed successfully.",
241242
updated_record) % {'count': updated_record,

tests/test_admin_list_editable.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ def test_message_user_no_changes(self):
116116

117117
messages = list(map(str, list(res.context['messages'])))
118118

119-
self.assertIn('No %s were changed due conflict errors' % force_text(self.TARGET._meta.verbose_name),
120-
messages)
119+
self.assertIn('Record with pk `%s` has been modified and was not updated' % id, messages)
121120
self.assertEqual(len(messages), 1)
122121

123122
def test_log_change(self):

0 commit comments

Comments
 (0)