Code

Ticket #1637: models.py.diff

File models.py.diff, 2.3 KB (added by Denis <kuzmichyov@…>, 8 years ago)
Line 
1Index: django/contrib/comments/models.py
2===================================================================
3--- django/contrib/comments/models.py   (revision 2697)
4+++ django/contrib/comments/models.py   (working copy)
5@@ -102,7 +102,7 @@
6         search_fields = ('comment', 'user__username')
7 
8     def __repr__(self):
9-        return "%s: %s..." % (self.get_user().username, self.comment[:100])
10+        return "%s: %s..." % (self.user.username, self.comment[:100])
11 
12     def get_absolute_url(self):
13         return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
14@@ -156,7 +156,7 @@
15 
16     def get_as_text(self):
17         return _('Posted by %(user)s at %(date)s\n\n%(comment)s\n\nhttp://%(domain)s%(url)s') % \
18-            {'user': self.get_user().username, 'date': self.submit_date,
19+            {'user': self.user.username, 'date': self.submit_date,
20             'comment': self.comment, 'domain': self.get_site().domain, 'url': self.get_absolute_url()}
21 
22 class FreeComment(models.Model):
23@@ -208,7 +208,7 @@
24 class KarmaScoreManager(models.Manager):
25     def vote(self, user_id, comment_id, score):
26         try:
27-            karma = self.get_object(comment__id__exact=comment_id, user__id__exact=user_id)
28+            karma = self.objects.get(comment__id__exact=comment_id, user__id__exact=user_id)
29         except self.model.DoesNotExist:
30             karma = self.model(None, user_id, comment_id, score, datetime.datetime.now())
31             karma.save()
32@@ -238,7 +238,7 @@
33         unique_together = (('user', 'comment'),)
34 
35     def __repr__(self):
36-        return _("%(score)d rating by %(user)s") % {'score': self.score, 'user': self.get_user()}
37+        return _("%(score)d rating by %(user)s") % {'score': self.score, 'user': self.user}
38 
39 class UserFlagManager(models.Manager):
40     def flag(self, comment, user):
41@@ -269,7 +269,7 @@
42         unique_together = (('user', 'comment'),)
43 
44     def __repr__(self):
45-        return _("Flag by %r") % self.get_user()
46+        return _("Flag by %r") % self.user
47 
48 class ModeratorDeletion(models.Model):
49     user = models.ForeignKey(User, verbose_name='moderator')
50@@ -281,4 +281,4 @@
51         unique_together = (('user', 'comment'),)
52 
53     def __repr__(self):
54-        return _("Moderator deletion by %r") % self.get_user()
55+        return _("Moderator deletion by %r") % self.user