diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-02-26 14:04:26 -0600 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-02-26 14:04:26 -0600 |
commit | e4e50a27653bd582e853e3f328ebc67cdd07b0e7 (patch) | |
tree | 91103c5f059d971a9ddd7986c9d6fbba1f313e63 | |
parent | 697c74c2de0cc940b45014f9becdfa55f961d193 (diff) | |
download | mediagoblin-e4e50a27653bd582e853e3f328ebc67cdd07b0e7.tar.lz mediagoblin-e4e50a27653bd582e853e3f328ebc67cdd07b0e7.tar.xz mediagoblin-e4e50a27653bd582e853e3f328ebc67cdd07b0e7.zip |
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!
-rw-r--r-- | mediagoblin/decorators.py | 20 |
1 files 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( |