diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-04-01 02:52:13 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-04-01 02:52:13 -0400 |
commit | f4441f0b40971d6ef8ae59b1fe231e78807c3935 (patch) | |
tree | 2c8087f6256629d1c99fdb5634b5dece69bf5f17 | |
parent | 45fb08dcfad1a415a536816f2caeed064bc96c0e (diff) | |
download | askbot-f4441f0b40971d6ef8ae59b1fe231e78807c3935.tar.gz askbot-f4441f0b40971d6ef8ae59b1fe231e78807c3935.tar.bz2 askbot-f4441f0b40971d6ef8ae59b1fe231e78807c3935.zip |
allowed extra context in the tags page
-rw-r--r-- | askbot/views/context.py | 8 | ||||
-rw-r--r-- | askbot/views/readers.py | 11 |
2 files changed, 11 insertions, 8 deletions
diff --git a/askbot/views/context.py b/askbot/views/context.py index eeaf6002..2b9ef5ea 100644 --- a/askbot/views/context.py +++ b/askbot/views/context.py @@ -1,11 +1,13 @@ """functions, preparing parts of context for the templates in the various views""" +from django.conf import settings as django_settings from django.utils import simplejson from django.utils.translation import ugettext as _ from askbot.conf import settings as askbot_settings from askbot import const from askbot.const import message_keys as msg from askbot.models import GroupMembership +from askbot.utils.loading import load_module def get_for_tag_editor(): #data for the tag editor @@ -50,3 +52,9 @@ def get_for_inbox(user): 'group_join_requests_count': group_join_requests_count } +def get_extra(context_module_setting, request, data): + extra_context = getattr(django_settings, context_module_setting, None) + if extra_context: + extra_context_getter = load_module(extra_context) + return extra_context_getter(request, data) + return {} diff --git a/askbot/views/readers.py b/askbot/views/readers.py index 1d4594bb..fc74c739 100644 --- a/askbot/views/readers.py +++ b/askbot/views/readers.py @@ -40,7 +40,6 @@ from askbot import const from askbot.utils import functions from askbot.utils.html import sanitize_html from askbot.utils.decorators import anonymous_forbidden, ajax_only, get_only -from askbot.utils.loading import load_module from askbot.search.state_manager import SearchState, DummySearchState from askbot.templatetags import extra_tags from askbot.conf import settings as askbot_settings @@ -307,6 +306,7 @@ def tags(request):#view showing a listing of available tags - plain list data['font_size'] = font_size data['tags'] = tags + data.update(context.get_extra('ASKBOT_TAGS_PAGE_EXTRA_CONTEXT', request, data)) if request.is_ajax(): template = get_template('tags/content.html') @@ -601,13 +601,8 @@ def question(request, id):#refactor - long subroutine. display question body, an data.update(context.get_for_tag_editor()) - extra_context = getattr( - django_settings, 'ASKBOT_QUESTION_PAGE_EXTRA_CONTEXT', None - ) - if extra_context: - extra_context_getter = load_module(extra_context) - extra_data = extra_context_getter(request, data) - data.update(extra_data) + extra = context.get_extra('ASKBOT_QUESTION_PAGE_EXTRA_CONTEXT', request, data) + data.update(extra) return render(request, 'question.html', data) |