Ticket #11710: change_message_unicode_name.patch

File change_message_unicode_name.patch, 3.1 KB (added by Joshua Russo, 15 years ago)
  • django/contrib/admin/options.py

     
    522522            for formset in formsets:
    523523                for added_object in formset.new_objects:
    524524                    change_message.append(_('Added %(name)s "%(object)s".')
    525                                           % {'name': added_object._meta.verbose_name,
     525                                          % {'name': force_unicode(added_object._meta.verbose_name),
    526526                                             'object': force_unicode(added_object)})
    527527                for changed_object, changed_fields in formset.changed_objects:
    528528                    change_message.append(_('Changed %(list)s for %(name)s "%(object)s".')
    529529                                          % {'list': get_text_list(changed_fields, _('and')),
    530                                              'name': changed_object._meta.verbose_name,
     530                                             'name': force_unicode(changed_object._meta.verbose_name),
    531531                                             'object': force_unicode(changed_object)})
    532532                for deleted_object in formset.deleted_objects:
    533533                    change_message.append(_('Deleted %(name)s "%(object)s".')
    534                                           % {'name': deleted_object._meta.verbose_name,
     534                                          % {'name': force_unicode(deleted_object._meta.verbose_name),
    535535                                             'object': force_unicode(deleted_object)})
    536536        change_message = ' '.join(change_message)
    537537        return change_message or _('No fields changed.')
  • tests/regressiontests/admin_views/models.py

     
    5454        return self.title
    5555
    5656    class Meta:
    57         verbose_name = u'¿Chapter?'
     57        # The u decorator was removed to test ticket #11710
     58        verbose_name = '¿Chapter?'
    5859
    5960class ChapterXtra1(models.Model):
    6061    chap = models.OneToOneField(Chapter, verbose_name=u'¿Chap?')
  • tests/regressiontests/admin_views/tests.py

     
    838838            "chapter_set-5-title": u"",
    839839            "chapter_set-5-content": u"",
    840840        }
    841 
    842         response = self.client.post('/test_admin/admin/admin_views/book/1/', post_data)
     841       
     842        try:
     843            response = self.client.post('/test_admin/admin/admin_views/book/1/', post_data)
     844        except UnicodeDecodeError:
     845            # For ticket #11710
     846            self.fail('A unicode decode error was detected')
    843847        self.failUnlessEqual(response.status_code, 302) # redirect somewhere
    844848
    845849    def testUnicodeDelete(self):
Back to Top