diff options
Diffstat (limited to 'askbot')
-rw-r--r-- | askbot/conf/sidebar_main.py | 18 | ||||
-rw-r--r-- | askbot/conf/sidebar_profile.py | 23 | ||||
-rw-r--r-- | askbot/conf/sidebar_question.py | 36 | ||||
-rw-r--r-- | askbot/doc/source/changelog.rst | 1 | ||||
-rw-r--r-- | askbot/doc/source/contributors.rst | 1 | ||||
-rw-r--r-- | askbot/media/style/style.css | 30 | ||||
-rw-r--r-- | askbot/media/style/style.less | 42 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py | 6 | ||||
-rw-r--r-- | askbot/setup_templates/settings.py.mustache | 16 | ||||
-rw-r--r-- | askbot/templates/main_page/sidebar.html | 4 | ||||
-rw-r--r-- | askbot/templates/question.html | 2 | ||||
-rw-r--r-- | askbot/templates/question/content.html | 2 | ||||
-rw-r--r-- | askbot/templates/question/sidebar.html | 4 | ||||
-rw-r--r-- | askbot/templates/user_profile/user.html | 11 | ||||
-rw-r--r-- | askbot/templatetags/extra_filters_jinja.py | 9 | ||||
-rw-r--r-- | askbot/tests/db_api_tests.py | 7 | ||||
-rw-r--r-- | askbot/tests/management_command_tests.py | 11 | ||||
-rw-r--r-- | askbot/tests/question_views_tests.py | 5 |
18 files changed, 120 insertions, 108 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/setup_templates/settings.py b/askbot/setup_templates/settings.py index 258a5989..1427e506 100644 --- a/askbot/setup_templates/settings.py +++ b/askbot/setup_templates/settings.py @@ -307,5 +307,9 @@ if 'ASKBOT_CSS_DEVEL' in locals() and ASKBOT_CSS_DEVEL == True: ) COMPRESS_JS_FILTERS = [] -COMPRESS_PARSER = 'compressor.parser.HtmlParser' +COMPRESS_PARSER = 'compressor.parser.HtmlParser' JINJA2_EXTENSIONS = ('compressor.contrib.jinja2ext.CompressorExtension',) + +# Use syncdb for tests instead of South migrations. Without this, some tests +# fail spuriously in MySQL. +SOUTH_TESTS_MIGRATE = False diff --git a/askbot/setup_templates/settings.py.mustache b/askbot/setup_templates/settings.py.mustache index f3c0a35b..f30297d7 100644 --- a/askbot/setup_templates/settings.py.mustache +++ b/askbot/setup_templates/settings.py.mustache @@ -27,6 +27,8 @@ DATABASES = { 'PASSWORD': '{{database_password}}', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. + 'TEST_CHARSET': 'utf8', # Setting the character set and collation to utf-8 + 'TEST_COLLATION': 'utf8_general_ci', # is necessary for MySQL tests to work properly. } } @@ -46,7 +48,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' #go to the site's live settings and enable the feature #"Email settings" -> "allow asking by email" # -# WARNING: command post_emailed_questions DELETES all +# WARNING: command post_emailed_questions DELETES all # emails from the mailbox each time # do not use your personal mail box here!!! # @@ -125,7 +127,7 @@ ROOT_URLCONF = os.path.basename(os.path.dirname(__file__)) + '.urls' #UPLOAD SETTINGS FILE_UPLOAD_TEMP_DIR = os.path.join( - os.path.dirname(__file__), + os.path.dirname(__file__), 'tmp' ).replace('\\','/') @@ -258,7 +260,7 @@ HAYSTACK_SITECONF = 'askbot.search.haystack' #http://django-haystack.readthedocs.org/en/v1.2.7/settings.html HAYSTACK_SEARCH_ENGINE = 'simple' -TINYMCE_COMPRESSOR = True +TINYMCE_COMPRESSOR = True TINYMCE_SPELLCHECKER = False TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, 'default/media/js/tinymce/') #TINYMCE_JS_URL = STATIC_URL + 'default/media/js/tinymce/tiny_mce.js' @@ -287,7 +289,7 @@ TINYMCE_DEFAULT_CONFIG = { } #delayed notifications, time in seconds, 15 mins by default -NOTIFICATION_DELAY_TIME = 60 * 15 +NOTIFICATION_DELAY_TIME = 60 * 15 GROUP_MESSAGING = { 'BASE_URL_GETTER_FUNCTION': 'askbot.models.user_get_profile_url', @@ -303,5 +305,9 @@ if 'ASKBOT_CSS_DEVEL' in locals() and ASKBOT_CSS_DEVEL == True: ) COMPRESS_JS_FILTERS = [] -COMPRESS_PARSER = 'compressor.parser.HtmlParser' +COMPRESS_PARSER = 'compressor.parser.HtmlParser' JINJA2_EXTENSIONS = ('compressor.contrib.jinja2ext.CompressorExtension',) + +# Use syncdb for tests instead of South migrations. Without this, some tests +# fail spuriously in MySQL. +SOUTH_TESTS_MIGRATE = False 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/db_api_tests.py b/askbot/tests/db_api_tests.py index 8d775fd0..1a7ad9e4 100644 --- a/askbot/tests/db_api_tests.py +++ b/askbot/tests/db_api_tests.py @@ -514,9 +514,14 @@ class GroupTests(AskbotTestCase): self.assertEqual(qa.groups.filter(name='private').exists(), True) def test_global_group_name_setting_changes_group_name(self): + orig_group_name = askbot_settings.GLOBAL_GROUP_NAME; askbot_settings.update('GLOBAL_GROUP_NAME', 'all-people') group = models.Group.objects.get_global_group() self.assertEqual(group.name, 'all-people') + # Revert the global group name, so we don't mess up other tests! + askbot_settings.update('GLOBAL_GROUP_NAME', orig_group_name); + group = models.Group.objects.get_global_group() + self.assertEqual(group.name, orig_group_name) def test_ask_global_group_by_id_works(self): group = models.Group.objects.get_global_group() @@ -698,5 +703,3 @@ class LinkPostingTests(AskbotTestCase): self.assert_no_link(question.html) self.edit_question(user=admin, question=question, body_text=text + ' ok') self.assert_has_link(question.html, 'http://wikipedia.org') - - 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 |