aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/decorators.py
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/decorators.py')
-rw-r--r--mediagoblin/decorators.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/mediagoblin/decorators.py b/mediagoblin/decorators.py
index f3535fcf..5b55ead7 100644
--- a/mediagoblin/decorators.py
+++ b/mediagoblin/decorators.py
@@ -21,7 +21,7 @@ from werkzeug.exceptions import Forbidden, NotFound
from werkzeug.urls import url_quote
from mediagoblin import mg_globals as mgg
-from mediagoblin.db.models import MediaEntry, User
+from mediagoblin.db.models import MediaEntry, User, MediaComment
from mediagoblin.tools.response import redirect, render_404
@@ -226,6 +226,24 @@ def get_media_entry_by_id(controller):
return wrapper
+def get_media_comment_by_id(controller):
+ """
+ Pass in a MediaComment based off of a url component
+ """
+ @wraps(controller)
+ def wrapper(request, *args, **kwargs):
+ comment = MediaComment.query.filter_by(
+ id=request.matchdict['comment']).first()
+ # Still no media? Okay, 404.
+ if not comment:
+ return render_404(request)
+
+ return controller(request, comment=comment, *args, **kwargs)
+
+ return wrapper
+
+
+
def get_workbench(func):
"""Decorator, passing in a workbench as kwarg which is cleaned up afterwards"""