Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #19114 -- Fixed LogEntry unicode representation

Thanks niko at neagee.net for the report and Emil Stenstrom for
the patch.
  • Loading branch information...
commit e0363c688d9b85124ec4fbac00debe5f4dc1e63c 1 parent 2a67374
Claude Paroz authored
13  django/contrib/admin/models.py
@@ -4,7 +4,7 @@
4 4
 from django.conf import settings
5 5
 from django.contrib.contenttypes.models import ContentType
6 6
 from django.contrib.admin.util import quote
7  
-from django.utils.translation import ugettext_lazy as _
  7
+from django.utils.translation import ugettext, ugettext_lazy as _
8 8
 from django.utils.encoding import smart_text
9 9
 from django.utils.encoding import python_2_unicode_compatible
10 10
 
@@ -42,13 +42,16 @@ def __repr__(self):
42 42
 
43 43
     def __str__(self):
44 44
         if self.action_flag == ADDITION:
45  
-            return _('Added "%(object)s".') % {'object': self.object_repr}
  45
+            return ugettext('Added "%(object)s".') % {'object': self.object_repr}
46 46
         elif self.action_flag == CHANGE:
47  
-            return _('Changed "%(object)s" - %(changes)s') % {'object': self.object_repr, 'changes': self.change_message}
  47
+            return ugettext('Changed "%(object)s" - %(changes)s') % {
  48
+                'object': self.object_repr,
  49
+                'changes': self.change_message,
  50
+            }
48 51
         elif self.action_flag == DELETION:
49  
-            return _('Deleted "%(object)s."') % {'object': self.object_repr}
  52
+            return ugettext('Deleted "%(object)s."') % {'object': self.object_repr}
50 53
 
51  
-        return _('LogEntry Object')
  54
+        return ugettext('LogEntry Object')
52 55
 
53 56
     def is_addition(self):
54 57
         return self.action_flag == ADDITION
4  tests/regressiontests/admin_util/tests.py
@@ -274,6 +274,10 @@ def test_logentry_unicode(self):
274 274
             six.text_type(log_entry).startswith('Deleted ')
275 275
         )
276 276
 
  277
+        # Make sure custom action_flags works
  278
+        log_entry.action_flag = 4
  279
+        self.assertEqual(six.text_type(log_entry), 'LogEntry Object')
  280
+
277 281
     def test_safestring_in_field_label(self):
278 282
         # safestring should not be escaped
279 283
         class MyForm(forms.Form):

0 notes on commit e0363c6

Please sign in to comment.
Something went wrong with that request. Please try again.