summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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/doc/source/contributors.rst1
-rw-r--r--askbot/media/style/style.css30
-rw-r--r--askbot/media/style/style.less42
-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
-rw-r--r--askbot/tests/management_command_tests.py11
-rw-r--r--askbot/tests/question_views_tests.py5
15 files changed, 99 insertions, 100 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/doc/source/contributors.rst b/askbot/doc/source/contributors.rst
index 44cd8ccb..85d252bc 100644
--- a/askbot/doc/source/contributors.rst
+++ b/askbot/doc/source/contributors.rst
@@ -47,6 +47,7 @@ Programming, bug fixes and documentation
* `Jorge López Pérez <https://github.com/adobo>`_
* `Zafer Cakmak <https://github.com/xaph>`_
* `Kevin Porterfield <http://www.shotgunsoftware.com>_`
+* `Robert Martin <https://github.com/bobbydavid>_`
Translations
------------
diff --git a/askbot/media/style/style.css b/askbot/media/style/style.css
index 3aab9f21..fc57e2b2 100644
--- a/askbot/media/style/style.css
+++ b/askbot/media/style/style.css
@@ -1742,7 +1742,7 @@ ul#related-tags li {
}
.groups-input,
.users-input {
- width: 152px;
+ width: 150px;
padding-left: 5px;
border: #c9c9b5 1px solid;
height: 25px;
@@ -1751,7 +1751,7 @@ ul#related-tags li {
.add-groups,
.add-users {
border: 0;
- margin-top: -2px;
+ margin: -2px 0 0 0 !important;
}
.share-input-col {
width: 160px;
@@ -1771,32 +1771,6 @@ ul#related-tags li {
width: 395px;
font-size: 14px;
}
-.groups-input,
-.users-input {
- width: 152px;
- padding-left: 5px;
- border: #c9c9b5 1px solid;
- height: 25px;
- font-size: 14px;
-}
-.add-groups,
-.add-users {
- border: 0;
- margin-top: -2px;
-}
-.add-everyone-group {
- text-align: center;
- margin: auto;
- display: block;
- padding: 0 10px;
-}
-#id_user,
-#id_user_author {
- height: 25px;
- padding-left: 5px;
- width: 395px;
- font-size: 14px;
-}
.title-desc {
color: #707070;
font-size: 13px;
diff --git a/askbot/media/style/style.less b/askbot/media/style/style.less
index efde976d..b68eaab2 100644
--- a/askbot/media/style/style.less
+++ b/askbot/media/style/style.less
@@ -1838,17 +1838,17 @@ ul#related-tags li {
.groups-input,
.users-input {
- width:152px;
- padding-left:5px;
- border:#c9c9b5 1px solid;
- height:25px;
+ width: 150px;
+ padding-left: 5px;
+ border: #c9c9b5 1px solid;
+ height: 25px;
font-size: 14px;
}
.add-groups,
.add-users {
- border:0;
- margin-top:-2px;
+ border: 0;
+ margin: -2px 0 0 0 !important;
}
.share-input-col {
@@ -1872,36 +1872,6 @@ ul#related-tags li {
font-size:14px;
}
-.groups-input,
-.users-input {
- width:152px;
- padding-left:5px;
- border:#c9c9b5 1px solid;
- height:25px;
- font-size: 14px;
-}
-
-.add-groups,
-.add-users {
- border:0;
- margin-top:-2px;
-}
-
-.add-everyone-group {
- text-align: center;
- margin: auto;
- display: block;
- padding: 0 10px;
-}
-
-#id_user,
-#id_user_author {
- height:25px;
- padding-left:5px;
- width:395px;
- font-size:14px;
-}
-
.title-desc {
color: @info-text;
font-size: 13px;
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)
diff --git a/askbot/tests/management_command_tests.py b/askbot/tests/management_command_tests.py
index e9341a8b..f1c6728d 100644
--- a/askbot/tests/management_command_tests.py
+++ b/askbot/tests/management_command_tests.py
@@ -34,20 +34,19 @@ class ManagementCommandTests(AskbotTestCase):
question = self.post_question(user=user_one)
comment = self.post_comment(user=user_one, parent_post=question)
number_of_gold = 50
- user_one.gold = number_of_gold
+ user_one.gold = number_of_gold
reputation = 20
- user_one.reputation = reputation
+ user_one.reputation = reputation
user_one.save()
# Create a second user and transfer all objects from 'user_one' to 'user_two'
user_two = self.create_user(username='unique')
+ user_two_pk = user_two.pk
management.call_command('merge_users', user_one.id, user_two.id)
# Check that the first user was deleted
self.assertEqual(models.User.objects.filter(pk=user_one.id).count(), 0)
# Explicitly check that the values assigned to user_one are now user_two's
self.assertEqual(user_two.posts.get_questions().filter(pk=question.id).count(), 1)
self.assertEqual(user_two.posts.get_comments().filter(pk=comment.id).count(), 1)
- #todo: change groups to django groups
- #then replace to 3 back to 2 in the line below
- user_two = models.User.objects.get(pk=2)
- self.assertEqual(user_two.gold, number_of_gold)
+ user_two = models.User.objects.get(pk=user_two_pk)
+ self.assertEqual(user_two.gold, number_of_gold)
self.assertEqual(user_two.reputation, reputation)
diff --git a/askbot/tests/question_views_tests.py b/askbot/tests/question_views_tests.py
index 9486b854..da3e081d 100644
--- a/askbot/tests/question_views_tests.py
+++ b/askbot/tests/question_views_tests.py
@@ -33,7 +33,7 @@ class PrivateQuestionViewsTests(AskbotTestCase):
dom = BeautifulSoup(response2.content)
title = dom.find('h1').text
self.assertTrue(unicode(const.POST_STATUS['private']) in title)
- question = models.Thread.objects.get(id=1)
+ question = models.Thread.objects.get()
self.assertEqual(question.title, self.qdata['title'])
self.assertFalse(models.Group.objects.get_global_group() in set(question.groups.all()))
@@ -114,7 +114,7 @@ class PrivateQuestionViewsTests(AskbotTestCase):
class PrivateAnswerViewsTests(AskbotTestCase):
-
+
def setUp(self):
self._backup = askbot_settings.GROUPS_ENABLED
askbot_settings.update('GROUPS_ENABLED', True)
@@ -147,7 +147,6 @@ class PrivateAnswerViewsTests(AskbotTestCase):
response = self.client.get(self.question.get_absolute_url())
self.assertFalse('some answer text' in response.content)
-
def test_private_checkbox_is_on_when_editing_private_answer(self):
answer = self.post_answer(
question=self.question, user=self.user, is_private=True