summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-05-24 05:31:29 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-05-24 05:31:29 -0400
commit98bfb63992324a717fa8ac550c6ff3ec1a7e3bc7 (patch)
tree74b1f048e544b7924fbc083ab91875acab0aa448
parenta0ba548049366cc37ad91f2824b119a1f45591e5 (diff)
downloadaskbot-98bfb63992324a717fa8ac550c6ff3ec1a7e3bc7.tar.gz
askbot-98bfb63992324a717fa8ac550c6ff3ec1a7e3bc7.tar.bz2
askbot-98bfb63992324a717fa8ac550c6ff3ec1a7e3bc7.zip
added option to hide ad blocks from logged in users
-rw-r--r--askbot/conf/sidebar_main.py18
-rw-r--r--askbot/conf/sidebar_profile.py23
-rw-r--r--askbot/conf/sidebar_question.py36
-rw-r--r--askbot/doc/source/changelog.rst1
-rw-r--r--askbot/templates/main_page/sidebar.html4
-rw-r--r--askbot/templates/question.html2
-rw-r--r--askbot/templates/question/content.html2
-rw-r--r--askbot/templates/question/sidebar.html4
-rw-r--r--askbot/templates/user_profile/user.html11
-rw-r--r--askbot/templatetags/extra_filters_jinja.py9
10 files changed, 83 insertions, 27 deletions
diff --git a/askbot/conf/sidebar_main.py b/askbot/conf/sidebar_main.py
index 8fa4bdf0..97b89e37 100644
--- a/askbot/conf/sidebar_main.py
+++ b/askbot/conf/sidebar_main.py
@@ -32,6 +32,15 @@ settings.register(
settings.register(
values.BooleanValue(
SIDEBAR_MAIN,
+ 'SIDEBAR_MAIN_HEADER_ANON_ONLY',
+ description=_('Show above only to anonymous users'),
+ default=False
+ )
+)
+
+settings.register(
+ values.BooleanValue(
+ SIDEBAR_MAIN,
'SIDEBAR_MAIN_SHOW_AVATARS',
description = _('Show avatar block in sidebar'),
help_text = _(
@@ -94,3 +103,12 @@ settings.register(
)
)
+settings.register(
+ values.BooleanValue(
+ SIDEBAR_MAIN,
+ 'SIDEBAR_MAIN_FOOTER_ANON_ONLY',
+ default=False,
+ description=_('Show above only to anonymous users')
+ )
+)
+
diff --git a/askbot/conf/sidebar_profile.py b/askbot/conf/sidebar_profile.py
index 948daa4a..a216de4b 100644
--- a/askbot/conf/sidebar_profile.py
+++ b/askbot/conf/sidebar_profile.py
@@ -16,8 +16,8 @@ SIDEBAR_PROFILE = ConfigurationGroup(
settings.register(
values.LongStringValue(
SIDEBAR_PROFILE,
- 'SIDEBAR_PROFILE_HEADER',
- description = _('Custom sidebar header'),
+ 'SIDEBAR_PROFILE',
+ description = _('Custom sidebar'),
default = '',
help_text = _(
'Use this area to enter content at the TOP of the sidebar'
@@ -25,23 +25,16 @@ settings.register(
'(as well as the sidebar footer), please '
'use the HTML validation service to make sure that '
'your input is valid and works well in all browsers.'
- )
+ )
)
)
+
settings.register(
- values.LongStringValue(
+ values.BooleanValue(
SIDEBAR_PROFILE,
- 'SIDEBAR_PROFILE_FOOTER',
- description = _('Custom sidebar footer'),
- default = '',
- help_text = _(
- 'Use this area to enter content at the BOTTOM of the sidebar'
- 'in HTML format. When using this option '
- '(as well as the sidebar header), please '
- 'use the HTML validation service to make sure that '
- 'your input is valid and works well in all browsers.'
- )
+ 'SIDEBAR_PROFILE_ANON_ONLY',
+ description=_('Show above only to anonymous users'),
+ default=False
)
)
-
diff --git a/askbot/conf/sidebar_question.py b/askbot/conf/sidebar_question.py
index ffe2f783..8d38692a 100644
--- a/askbot/conf/sidebar_question.py
+++ b/askbot/conf/sidebar_question.py
@@ -27,6 +27,15 @@ settings.register(
)
settings.register(
+ values.BooleanValue(
+ SIDEBAR_QUESTION,
+ 'QUESTION_PAGE_TOP_BANNER_ANON_ONLY',
+ default=False,
+ description=_('Show above only to anonymous users'),
+ )
+)
+
+settings.register(
values.LongStringValue(
SIDEBAR_QUESTION,
'QUESTION_PAGE_ANSWER_BANNER',
@@ -42,6 +51,16 @@ settings.register(
)
settings.register(
+ values.BooleanValue(
+ SIDEBAR_QUESTION,
+ 'QUESTION_PAGE_ANSWER_BANNER_ANON_ONLY',
+ default=False,
+ description=_('Show above only to anonymous users'),
+ )
+)
+
+
+settings.register(
values.LongStringValue(
SIDEBAR_QUESTION,
'SIDEBAR_QUESTION_HEADER',
@@ -60,6 +79,15 @@ settings.register(
settings.register(
values.BooleanValue(
SIDEBAR_QUESTION,
+ 'SIDEBAR_QUESTION_HEADER_ANON_ONLY',
+ default=False,
+ description=_('Show above only to anonymous users')
+ )
+)
+
+settings.register(
+ values.BooleanValue(
+ SIDEBAR_QUESTION,
'SIDEBAR_QUESTION_SHOW_TAGS',
description = _('Show tag list in sidebar'),
help_text = _(
@@ -113,3 +141,11 @@ settings.register(
)
)
+settings.register(
+ values.BooleanValue(
+ SIDEBAR_QUESTION,
+ 'SIDEBAR_QUESTION_FOOTER_ANON_ONLY',
+ default=False,
+ description=_('Show above only to anonymous users')
+ )
+)
diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst
index cda70e77..6d14dd36 100644
--- a/askbot/doc/source/changelog.rst
+++ b/askbot/doc/source/changelog.rst
@@ -3,6 +3,7 @@ Changes in Askbot
Development version
-------------------
+* Added option to hide ad blocks from logged in users
* Applied Askbot templates to the settings control panel
* Added option to auto-follow questions by the question posters with default "on"
* Support for Django 1.5
diff --git a/askbot/templates/main_page/sidebar.html b/askbot/templates/main_page/sidebar.html
index 7acbe091..610d2b60 100644
--- a/askbot/templates/main_page/sidebar.html
+++ b/askbot/templates/main_page/sidebar.html
@@ -1,6 +1,6 @@
{% import "macros.html" as macros %}
-{% if settings.SIDEBAR_MAIN_HEADER %}
+{% if 'SIDEBAR_MAIN_HEADER'|show_block_to(request.user) %}
<div class="box">
{{ settings.SIDEBAR_MAIN_HEADER }}
</div>
@@ -22,7 +22,7 @@
{% include "widgets/related_tags.html" %}
{% endif %}
-{% if settings.SIDEBARE_MAIN_FOOTER %}
+{% if 'SIDEBAR_MAIN_FOOTER'|show_block_to(request.user) %}
<div class="box">
{{ settings.SIDEBAR_MAIN_FOOTER }}
</div>
diff --git a/askbot/templates/question.html b/askbot/templates/question.html
index 13593adc..ca2f4022 100644
--- a/askbot/templates/question.html
+++ b/askbot/templates/question.html
@@ -285,7 +285,7 @@
</script>
{% endblock %}
{% block content %}
- {% if settings.QUESTION_PAGE_TOP_BANNER %}
+ {% if 'QUESTION_PAGE_TOP_BANNER'|show_block_to(request.user) %}
<div class="banner">{{ settings.QUESTION_PAGE_TOP_BANNER|safe }}</div>
{% endif %}
{% if is_cacheable %}
diff --git a/askbot/templates/question/content.html b/askbot/templates/question/content.html
index 23286ce0..c8fef9a6 100644
--- a/askbot/templates/question/content.html
+++ b/askbot/templates/question/content.html
@@ -12,7 +12,7 @@
<div class="clean"></div>
{% for answer in answers %}
- {% if answers|length > 1 and loop.index == 2 %}
+ {% if loop.index == 2 and 'QUESTION_PAGE_ANSWER_BANNER'|show_block_to(request.user) %}
<div class="banner">{{ settings.QUESTION_PAGE_ANSWER_BANNER|safe }}</div>
{% endif %}
{% include "question/answer_card.html" %}
diff --git a/askbot/templates/question/sidebar.html b/askbot/templates/question/sidebar.html
index c11a4336..523f01ff 100644
--- a/askbot/templates/question/sidebar.html
+++ b/askbot/templates/question/sidebar.html
@@ -1,5 +1,5 @@
{% import "macros.html" as macros %}
-{% if settings.SIDEBAR_QUESTION_HEADER %}
+{% if 'SIDEBAR_QUESTION_HEADER'|show_block_to(request.user) %}
<div class="box">
{{ settings.SIDEBAR_QUESTION_HEADER }}
</div>
@@ -173,7 +173,7 @@
{#% endcache %#}
{% endif %}
-{% if settings.SIDEBAR_QUESTION_FOOTER %}
+{% if 'SIDEBAR_QUESTION_FOOTER'|show_block_to(request.user) %}
<div class="box">
{{ settings.SIDEBAR_QUESTION_FOOTER }}
</div>
diff --git a/askbot/templates/user_profile/user.html b/askbot/templates/user_profile/user.html
index 3aee3cfa..c72dc857 100644
--- a/askbot/templates/user_profile/user.html
+++ b/askbot/templates/user_profile/user.html
@@ -36,11 +36,10 @@
{% endblock %}
{% endblock %}
{% block sidebar %}
-<div class="box">
- {{ settings.SIDEBAR_PROFILE_HEADER }}
-</div>
-<div class="box">
- {{ settings.SIDEBAR_PROFILE_FOOTER }}
-</div>
+ {% if 'SIDEBAR_PROFILE'|show_block_to(request.user) %}
+ <div class="box">
+ {{ settings.SIDEBAR_PROFILE }}
+ </div>
+ {% endif %}
{% endblock %}
<!-- end of user.html -->
diff --git a/askbot/templatetags/extra_filters_jinja.py b/askbot/templatetags/extra_filters_jinja.py
index dccd9a2a..93acea84 100644
--- a/askbot/templatetags/extra_filters_jinja.py
+++ b/askbot/templatetags/extra_filters_jinja.py
@@ -79,6 +79,15 @@ def safe_urlquote(text, quote_plus = False):
return urllib.quote(text.encode('utf8'))
@register.filter
+def show_block_to(block_name, user):
+ block = getattr(askbot_settings, block_name)
+ if block:
+ flag_name = block_name + '_ANON_ONLY'
+ require_anon = getattr(askbot_settings, flag_name, False)
+ return (require_anon is False) or user.is_anonymous()
+ return False
+
+@register.filter
def strip_path(url):
"""removes path part of the url"""
return url_utils.strip_path(url)