aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2014-04-07 16:58:54 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-04-07 16:58:54 -0500
commit2edd6b0b91b38dd77837cdb21ac3a401c797dd27 (patch)
treeb7de8e0dfd3b72e7fc9fa714794fa9823805a900
parentbfb99d65f4e92d018a73b67bed2cea9d629a41e2 (diff)
downloadmediagoblin-2edd6b0b91b38dd77837cdb21ac3a401c797dd27.tar.lz
mediagoblin-2edd6b0b91b38dd77837cdb21ac3a401c797dd27.tar.xz
mediagoblin-2edd6b0b91b38dd77837cdb21ac3a401c797dd27.zip
Adding a general purpose context hook for the media display page.
Since the media template name gets swapped out for each media type, normal context hooks don't work if you want to affect all media displays. This gives a general purpose hook. This commit sponsored by Kẏra. Thanks! :)
-rw-r--r--mediagoblin/user_pages/views.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py
index 64fa793e..78751a28 100644
--- a/mediagoblin/user_pages/views.py
+++ b/mediagoblin/user_pages/views.py
@@ -31,6 +31,7 @@ from mediagoblin.user_pages.lib import (send_comment_email,
add_media_to_collection, build_report_object)
from mediagoblin.notifications import trigger_notification, \
add_comment_subscription, mark_comment_notification_seen
+from mediagoblin.tools.pluginapi import hook_transform
from mediagoblin.decorators import (uses_pagination, get_user_media_entry,
get_media_entry_by_id, user_has_privilege, user_not_banned,
@@ -146,14 +147,23 @@ def media_home(request, media, page, **kwargs):
media_template_name = media.media_manager.display_template
+ context = {
+ 'media': media,
+ 'comments': comments,
+ 'pagination': pagination,
+ 'comment_form': comment_form,
+ 'app_config': mg_globals.app_config}
+
+ # Since the media template name gets swapped out for each media
+ # type, normal context hooks don't work if you want to affect all
+ # media displays. This gives a general purpose hook.
+ context = hook_transform(
+ "media_home_context", context)
+
return render_to_response(
request,
media_template_name,
- {'media': media,
- 'comments': comments,
- 'pagination': pagination,
- 'comment_form': comment_form,
- 'app_config': mg_globals.app_config})
+ context)
@get_media_entry_by_id