Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5909 -- Made the various django.contrib.comment models more ro…

…bust in

the face of non-ASCII characters by giving them a __unicode__ method and
letting the default __repr__ use that. Patches from prairiedogg and scompt.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6742 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c3a867228b34799c9d31f3da3660673fce2d48d0 1 parent f86e54e
Malcolm Tredinnick authored November 29, 2007
10  django/contrib/comments/models.py
@@ -102,7 +102,7 @@ class Admin:
102 102
         date_hierarchy = 'submit_date'
103 103
         search_fields = ('comment', 'user__username')
104 104
 
105  
-    def __repr__(self):
  105
+    def __unicode__(self):
106 106
         return "%s: %s..." % (self.user.username, self.comment[:100])
107 107
 
108 108
     def get_absolute_url(self):
@@ -190,7 +190,7 @@ class Admin:
190 190
         date_hierarchy = 'submit_date'
191 191
         search_fields = ('comment', 'person_name')
192 192
 
193  
-    def __repr__(self):
  193
+    def __unicode__(self):
194 194
         return "%s: %s..." % (self.person_name, self.comment[:100])
195 195
 
196 196
     def get_absolute_url(self):
@@ -244,7 +244,7 @@ class Meta:
244 244
         verbose_name_plural = _('karma scores')
245 245
         unique_together = (('user', 'comment'),)
246 246
 
247  
-    def __repr__(self):
  247
+    def __unicode__(self):
248 248
         return _("%(score)d rating by %(user)s") % {'score': self.score, 'user': self.user}
249 249
 
250 250
 class UserFlagManager(models.Manager):
@@ -275,7 +275,7 @@ class Meta:
275 275
         verbose_name_plural = _('user flags')
276 276
         unique_together = (('user', 'comment'),)
277 277
 
278  
-    def __repr__(self):
  278
+    def __unicode__(self):
279 279
         return _("Flag by %r") % self.user
280 280
 
281 281
 class ModeratorDeletion(models.Model):
@@ -287,5 +287,5 @@ class Meta:
287 287
         verbose_name_plural = _('moderator deletions')
288 288
         unique_together = (('user', 'comment'),)
289 289
 
290  
-    def __repr__(self):
  290
+    def __unicode__(self):
291 291
         return _("Moderator deletion by %r") % self.user
13  django/contrib/comments/tests.py
... ...
@@ -0,0 +1,13 @@
  1
+# coding: utf-8
  2
+
  3
+r"""
  4
+>>> from django.contrib.comments.models import Comment
  5
+>>> from django.contrib.auth.models import User
  6
+>>> u = User.objects.create_user('commenttestuser', 'commenttest@example.com', 'testpw')
  7
+>>> c = Comment(user=u, comment=u'\xe2')
  8
+>>> c
  9
+<Comment: commenttestuser: â...>
  10
+>>> print c
  11
+commenttestuser: â...
  12
+"""
  13
+

0 notes on commit c3a8672

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