Ticket #1637: models.py.2.diff

File models.py.2.diff, 2.8 KB (added by Denis <kuzmichyov@…>, 9 years ago)

Missed 1 line in the 1st variant

  • django/contrib/comments/models.py

     
    102102        search_fields = ('comment', 'user__username')
    103103
    104104    def __repr__(self):
    105         return "%s: %s..." % (self.get_user().username, self.comment[:100])
     105        return "%s: %s..." % (self.user.username, self.comment[:100])
    106106
    107107    def get_absolute_url(self):
    108108        return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     
    156156
    157157    def get_as_text(self):
    158158        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,
    160160            'comment': self.comment, 'domain': self.get_site().domain, 'url': self.get_absolute_url()}
    161161
    162162class FreeComment(models.Model):
     
    208208class KarmaScoreManager(models.Manager):
    209209    def vote(self, user_id, comment_id, score):
    210210        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)
    212212        except self.model.DoesNotExist:
    213213            karma = self.model(None, user_id, comment_id, score, datetime.datetime.now())
    214214            karma.save()
     
    238238        unique_together = (('user', 'comment'),)
    239239
    240240    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}
    242242
    243243class UserFlagManager(models.Manager):
    244244    def flag(self, comment, user):
     
    250250        if int(comment.user_id) == int(user.id):
    251251            return # A user can't flag his own comment. Fail silently.
    252252        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)
    254254        except self.model.DoesNotExist:
    255255            from django.core.mail import mail_managers
    256256            f = self.model(None, user.id, comment.id, None)
     
    269269        unique_together = (('user', 'comment'),)
    270270
    271271    def __repr__(self):
    272         return _("Flag by %r") % self.get_user()
     272        return _("Flag by %r") % self.user
    273273
    274274class ModeratorDeletion(models.Model):
    275275    user = models.ForeignKey(User, verbose_name='moderator')
     
    281281        unique_together = (('user', 'comment'),)
    282282
    283283    def __repr__(self):
    284         return _("Moderator deletion by %r") % self.get_user()
     284        return _("Moderator deletion by %r") % self.user
Back to Top