diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2011-05-26 23:09:33 +0200 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2011-05-26 23:09:33 +0200 |
commit | aba81c9f20acd0fa3fd1a31db678fccfba8777d1 (patch) | |
tree | 1eb4752d3e2d5fe490659234fbd1dc3cb63884bc /mediagoblin/decorators.py | |
parent | e698dedad5a3baa73a6bc0025a77a64c384e5bd4 (diff) | |
download | mediagoblin-aba81c9f20acd0fa3fd1a31db678fccfba8777d1.tar.lz mediagoblin-aba81c9f20acd0fa3fd1a31db678fccfba8777d1.tar.xz mediagoblin-aba81c9f20acd0fa3fd1a31db678fccfba8777d1.zip |
Starting "edit" functionality.
This adds a link to the "edit" form, the form, the view for
displaying the form and that's about it.
Diffstat (limited to 'mediagoblin/decorators.py')
-rw-r--r-- | mediagoblin/decorators.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mediagoblin/decorators.py b/mediagoblin/decorators.py index ff3f0b5e..fe631112 100644 --- a/mediagoblin/decorators.py +++ b/mediagoblin/decorators.py @@ -99,3 +99,23 @@ def get_user_media_entry(controller): return controller(request, media=media, *args, **kwargs) return _make_safe(wrapper, controller) + +def get_media_entry_by_id(controller): + """ + Pass in a MediaEntry based off of a url component + """ + def wrapper(request, *args, **kwargs): + try: + media = request.db.MediaEntry.find_one( + {'_id': ObjectId(request.matchdict['media']), + 'state': 'processed'}) + except InvalidId: + return exc.HTTPNotFound() + + # Still no media? Okay, 404. + if not media: + return exc.HTTPNotFound() + + return controller(request, media=media, *args, **kwargs) + + return _make_safe(wrapper, controller) |