Ticket #12952: admin_history.diff
File admin_history.diff, 4.0 KB (added by , 13 years ago) |
---|
-
../django/contrib/admin/options.py
636 636 """ 637 637 Construct a change message from a changed object. 638 638 """ 639 640 def convert_changed_list(obj, changed_data): 641 cls = type(obj) 642 verbose_names = [] 643 for field in changed_data: 644 try: 645 verbose_names.append(cls._meta.get_field_by_name(field)[0].verbose_name) 646 except FieldDoesNotExist: 647 verbose_names.append(field) 648 return verbose_names 649 639 650 change_message = [] 640 651 if form.changed_data: 641 change_message.append(_('Changed %s.') % get_text_list(form.changed_data, _('and'))) 652 change_message.append(_('Changed %s.') % 653 get_text_list(convert_changed_list(form.instance, form.changed_data), _('and'))) 642 654 643 655 if formsets: 644 656 for formset in formsets: … … 648 660 'object': force_unicode(added_object)}) 649 661 for changed_object, changed_fields in formset.changed_objects: 650 662 change_message.append(_('Changed %(list)s for %(name)s "%(object)s".') 651 % {'list': get_text_list(changed_fields, _('and')), 663 % {'list': get_text_list(convert_changed_list(changed_object, changed_fields), 664 _('and')), 652 665 'name': force_unicode(changed_object._meta.verbose_name), 653 666 'object': force_unicode(changed_object)}) 654 667 for deleted_object in formset.deleted_objects: -
../tests/regressiontests/admin_views/tests.py
1047 1047 1048 1048 response = self.client.get('/test_admin/admin/secure-view/') 1049 1049 self.assertContains(response, 'id="login-form"') 1050 1051 def testHistoryView(self): 1052 change_dict = {'title' : 'Ikke fordømt', 1053 'content': '<p>edited article</p>', 1054 'date_0': '2008-03-18', 'date_1': '10:54:39', 1055 'section': 1} 1056 1057 self.client.get('/test_admin/admin/') 1058 self.client.post('/test_admin/admin/', self.changeuser_login) 1059 post = self.client.post('/test_admin/admin/admin_views/article/1/', change_dict) 1060 self.assertEqual(Article.objects.get(pk=1).content, '<p>edited article</p>') 1061 response = self.client.get('/test_admin/admin/admin_views/article/1/history/') 1062 self.assertEqual(response.status_code, 200) 1063 self.assertContains(response, u'<td>changeuser (Change User)</td>') 1064 self.assertContains(response, u'<td>Changed ¿Name?, content and ¿Date published?.</td>') 1065 1066 1067 1068 1050 1069 1051 1070 1052 1071 class AdminViewDeletedObjectsTest(TestCase): -
../tests/regressiontests/admin_views/models.py
25 25 """ 26 26 A simple article to test admin views. Test backwards compatibility. 27 27 """ 28 title = models.CharField(max_length=100 )28 title = models.CharField(max_length=100, verbose_name=u'¿Name?') 29 29 content = models.TextField() 30 date = models.DateTimeField( )31 section = models.ForeignKey(Section, null=True, blank=True )30 date = models.DateTimeField(verbose_name=u'¿Date published?') 31 section = models.ForeignKey(Section, null=True, blank=True, verbose_name=u'¿Section?') 32 32 33 33 def __unicode__(self): 34 34 return self.title