Simplifying the "id:" url detection, per Elrond's suggestion.

As pointed out, we didn't need that nested if.

This commit sponsored by Paul Kuriakose.  Thank you!
This commit is contained in:
Christopher Allan Webber 2013-02-26 14:04:26 -06:00
parent 697c74c2de
commit e4e50a2765

View File

@ -130,17 +130,15 @@ def get_user_media_entry(controller):
# might not be a slug, might be an id, but whatever # might not be a slug, might be an id, but whatever
media_slug = request.matchdict['media'] media_slug = request.matchdict['media']
if u":" in media_slug: # if it starts with id: it actually isn't a slug, it's an id.
# okay, it's not actually a slug, it's some kind of identifier, if media_slug.startswith(u'id:'):
# probably id: try:
if media_slug.startswith(u'id:'): media = MediaEntry.query.filter_by(
try: id=int(media_slug[3:]),
media = MediaEntry.query.filter_by( state=u'processed',
id=int(media_slug[3:]), uploader=user.id).first()
state=u'processed', except ValueError:
uploader=user.id).first() raise NotFound()
except ValueError:
raise NotFound()
else: else:
# no magical id: stuff? It's a slug! # no magical id: stuff? It's a slug!
media = MediaEntry.query.filter_by( media = MediaEntry.query.filter_by(