diff --git django/contrib/admin/models.py django/contrib/admin/models.py
index 73810b7..5a1e0d8 100644
|
|
class LogEntry(models.Model):
|
33 | 33 | def __repr__(self): |
34 | 34 | return smart_unicode(self.action_time) |
35 | 35 | |
| 36 | def __unicode__(self): |
| 37 | |
| 38 | if self.action_flag == ADDITION: |
| 39 | return _('Added "%(object)s".') % {'object': self.object_repr} |
| 40 | elif self.action_flag == CHANGE: |
| 41 | return _('Changed "%(object)s" - %(changes)s') % {'object': self.object_repr, 'changes': self.change_message} |
| 42 | elif self.action_flag == DELETION: |
| 43 | return _('Deleted "%(object)s."') % {'object': self.object_repr} |
| 44 | |
| 45 | return_value = _('LogEntry Object') |
| 46 | |
36 | 47 | def is_addition(self): |
37 | 48 | return self.action_flag == ADDITION |
38 | 49 | |
… |
… |
class LogEntry(models.Model):
|
53 | 64 | """ |
54 | 65 | if self.content_type and self.object_id: |
55 | 66 | return mark_safe(u"%s/%s/%s/" % (self.content_type.app_label, self.content_type.model, quote(self.object_id))) |
56 | | return None |
57 | | No newline at end of file |
| 67 | return None |
diff --git tests/regressiontests/admin_util/tests.py tests/regressiontests/admin_util/tests.py
index f4b3dd9..e27417f 100644
|
|
class UtilTests(unittest.TestCase):
|
235 | 235 | label_for_field('guest', Event, return_attr=True), |
236 | 236 | ('awesome guest', None), |
237 | 237 | ) |
| 238 | |
| 239 | def test_logentry_unicode(self): |
| 240 | """ |
| 241 | Regression test for #15661 |
| 242 | """ |
| 243 | log_entry = admin.models.LogEntry() |
| 244 | |
| 245 | log_entry.action_flag = admin.models.ADDITION |
| 246 | self.assertTrue( |
| 247 | log_entry.__unicode__().startswith('Added ') |
| 248 | ) |
| 249 | |
| 250 | log_entry.action_flag = admin.models.CHANGE |
| 251 | self.assertTrue( |
| 252 | log_entry.__unicode__().startswith('Changed ') |
| 253 | ) |
| 254 | |
| 255 | log_entry.action_flag = admin.models.DELETION |
| 256 | self.assertTrue( |
| 257 | log_entry.__unicode__().startswith('Deleted ') |
| 258 | ) |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |