Add __unicode__ representation to Notification and MediaCommentMixin
Instead of having __repr__ return a unicode object which it should not do, we use the __unicode__ method to allow use of Notification and MediaCommentMixin objects in unicode strings.
This commit is contained in:
parent
0e9aa9db14
commit
dc19e98d98
@ -305,13 +305,20 @@ class MediaCommentMixin(object):
|
|||||||
"""
|
"""
|
||||||
return cleaned_markdown_conversion(self.content)
|
return cleaned_markdown_conversion(self.content)
|
||||||
|
|
||||||
def __repr__(self):
|
def __unicode__(self):
|
||||||
return u'<{klass} #{id} {author} "{comment}">'.format(
|
return u'<{klass} #{id} {author} "{comment}">'.format(
|
||||||
klass=self.__class__.__name__,
|
klass=self.__class__.__name__,
|
||||||
id=self.id,
|
id=self.id,
|
||||||
author=self.get_author,
|
author=self.get_author,
|
||||||
comment=self.content)
|
comment=self.content)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '<{klass} #{id} {author} "{comment}">'.format(
|
||||||
|
klass=self.__class__.__name__,
|
||||||
|
id=self.id,
|
||||||
|
author=self.get_author,
|
||||||
|
comment=self.content)
|
||||||
|
|
||||||
|
|
||||||
class CollectionMixin(GenerateSlugMixin):
|
class CollectionMixin(GenerateSlugMixin):
|
||||||
def check_slug_used(self, slug):
|
def check_slug_used(self, slug):
|
||||||
|
@ -820,6 +820,14 @@ class Notification(Base):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
return '<{klass} #{id}: {user}: {subject} ({seen})>'.format(
|
||||||
|
id=self.id,
|
||||||
|
klass=self.__class__.__name__,
|
||||||
|
user=self.user,
|
||||||
|
subject=getattr(self, 'subject', None),
|
||||||
|
seen='unseen' if not self.seen else 'seen')
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
return u'<{klass} #{id}: {user}: {subject} ({seen})>'.format(
|
return u'<{klass} #{id}: {user}: {subject} ({seen})>'.format(
|
||||||
id=self.id,
|
id=self.id,
|
||||||
klass=self.__class__.__name__,
|
klass=self.__class__.__name__,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user