def main_mediafile(self):
pass
+ @property
+ def slug_or_id(self):
+ return (self.slug or self._id)
+
def url_for_self(self, urlgen, **extra_args):
"""
Generate an appropriate url for ourselves
"""
uploader = self.get_uploader
- if self.get('slug'):
- return urlgen(
- 'mediagoblin.user_pages.media_home',
- user=uploader.username,
- media=self.slug,
- **extra_args)
- else:
- return urlgen(
- 'mediagoblin.user_pages.media_home',
- user=uploader.username,
- media=unicode(self._id),
- **extra_args)
+ return urlgen(
+ 'mediagoblin.user_pages.media_home',
+ user=uploader.username,
+ media=self.slug_or_id,
+ **extra_args)
def get_fail_exception(self):
"""
id = Column(Integer, primary_key=True)
uploader = Column(Integer, ForeignKey('users.id'), nullable=False)
title = Column(Unicode, nullable=False)
- slug = Column(Unicode, nullable=False)
+ slug = Column(Unicode)
created = Column(DateTime, nullable=False, default=datetime.datetime.now)
description = Column(UnicodeText) # ??
description_html = Column(UnicodeText) # ??
<a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
comment = comment._id,
user = media.get_uploader.username,
- media = media.slug) }}#comment">
+ media = media.slug_or_id) }}#comment">
{{ comment.created.strftime("%I:%M%p %Y-%m-%d") }}
</a>
</div>