Ticket #1637: models.py.2.diff
File models.py.2.diff, 2.8 KB (added by , 19 years ago) |
---|
-
django/contrib/comments/models.py
102 102 search_fields = ('comment', 'user__username') 103 103 104 104 def __repr__(self): 105 return "%s: %s..." % (self. get_user().username, self.comment[:100])105 return "%s: %s..." % (self.user.username, self.comment[:100]) 106 106 107 107 def get_absolute_url(self): 108 108 return self.get_content_object().get_absolute_url() + "#c" + str(self.id) … … 156 156 157 157 def get_as_text(self): 158 158 return _('Posted by %(user)s at %(date)s\n\n%(comment)s\n\nhttp://%(domain)s%(url)s') % \ 159 {'user': self. get_user().username, 'date': self.submit_date,159 {'user': self.user.username, 'date': self.submit_date, 160 160 'comment': self.comment, 'domain': self.get_site().domain, 'url': self.get_absolute_url()} 161 161 162 162 class FreeComment(models.Model): … … 208 208 class KarmaScoreManager(models.Manager): 209 209 def vote(self, user_id, comment_id, score): 210 210 try: 211 karma = self. get_object(comment__id__exact=comment_id, user__id__exact=user_id)211 karma = self.objects.get(comment__id__exact=comment_id, user__id__exact=user_id) 212 212 except self.model.DoesNotExist: 213 213 karma = self.model(None, user_id, comment_id, score, datetime.datetime.now()) 214 214 karma.save() … … 238 238 unique_together = (('user', 'comment'),) 239 239 240 240 def __repr__(self): 241 return _("%(score)d rating by %(user)s") % {'score': self.score, 'user': self. get_user()}241 return _("%(score)d rating by %(user)s") % {'score': self.score, 'user': self.user} 242 242 243 243 class UserFlagManager(models.Manager): 244 244 def flag(self, comment, user): … … 250 250 if int(comment.user_id) == int(user.id): 251 251 return # A user can't flag his own comment. Fail silently. 252 252 try: 253 f = self. get_object(user__id__exact=user.id, comment__id__exact=comment.id)253 f = self.objects.get(user__id__exact=user.id, comment__id__exact=comment.id) 254 254 except self.model.DoesNotExist: 255 255 from django.core.mail import mail_managers 256 256 f = self.model(None, user.id, comment.id, None) … … 269 269 unique_together = (('user', 'comment'),) 270 270 271 271 def __repr__(self): 272 return _("Flag by %r") % self. get_user()272 return _("Flag by %r") % self.user 273 273 274 274 class ModeratorDeletion(models.Model): 275 275 user = models.ForeignKey(User, verbose_name='moderator') … … 281 281 unique_together = (('user', 'comment'),) 282 282 283 283 def __repr__(self): 284 return _("Moderator deletion by %r") % self. get_user()284 return _("Moderator deletion by %r") % self.user