From e4e50a27653bd582e853e3f328ebc67cdd07b0e7 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Tue, 26 Feb 2013 14:04:26 -0600 Subject: [PATCH] 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! --- mediagoblin/decorators.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mediagoblin/decorators.py b/mediagoblin/decorators.py index b6f6f909..fbf7b188 100644 --- a/mediagoblin/decorators.py +++ b/mediagoblin/decorators.py @@ -130,17 +130,15 @@ def get_user_media_entry(controller): # might not be a slug, might be an id, but whatever media_slug = request.matchdict['media'] - if u":" in media_slug: - # okay, it's not actually a slug, it's some kind of identifier, - # probably id: - if media_slug.startswith(u'id:'): - try: - media = MediaEntry.query.filter_by( - id=int(media_slug[3:]), - state=u'processed', - uploader=user.id).first() - except ValueError: - raise NotFound() + # if it starts with id: it actually isn't a slug, it's an id. + if media_slug.startswith(u'id:'): + try: + media = MediaEntry.query.filter_by( + id=int(media_slug[3:]), + state=u'processed', + uploader=user.id).first() + except ValueError: + raise NotFound() else: # no magical id: stuff? It's a slug! media = MediaEntry.query.filter_by(