aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/models.py
diff options
context:
space:
mode:
authorTryggvi Bjorgvinsson <tryggvib@fsfi.is>2014-07-19 12:35:50 +0000
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-07-25 14:37:57 -0500
commitdc19e98d98bc53d983d2fab73be53cbf95b42ffa (patch)
treeaa86d707ac637ef567915cd4e78c309747ac83b0 /mediagoblin/db/models.py
parent0e9aa9db14b19e0941fe4e585b929a575f8b7d1a (diff)
downloadmediagoblin-dc19e98d98bc53d983d2fab73be53cbf95b42ffa.tar.lz
mediagoblin-dc19e98d98bc53d983d2fab73be53cbf95b42ffa.tar.xz
mediagoblin-dc19e98d98bc53d983d2fab73be53cbf95b42ffa.zip
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.
Diffstat (limited to 'mediagoblin/db/models.py')
-rw-r--r--mediagoblin/db/models.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index aaceb599..c2d101ac 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -820,6 +820,14 @@ class Notification(Base):
}
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(
id=self.id,
klass=self.__class__.__name__,