From 6e4e975636612756751417b42ab8f354e03bd10e Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Wed, 7 Nov 2012 16:21:33 -0300 Subject: added a setting to disable RSS feed --- askbot/conf/social_sharing.py | 11 ++++++++++- askbot/doc/source/changelog.rst | 1 + askbot/feed.py | 6 +++++- askbot/templates/main_page/tab_bar.html | 2 ++ askbot/templates/question/sidebar.html | 2 ++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/askbot/conf/social_sharing.py b/askbot/conf/social_sharing.py index 9a0f8ad4..c7c29151 100644 --- a/askbot/conf/social_sharing.py +++ b/askbot/conf/social_sharing.py @@ -8,10 +8,19 @@ from django.utils.translation import ugettext as _ SOCIAL_SHARING = ConfigurationGroup( 'SOCIAL_SHARING', - _('Sharing content on social networks'), + _('Content sharing'), super_group = EXTERNAL_SERVICES ) +settings.register( + BooleanValue( + SOCIAL_SHARING, + 'RSS_ENABLED', + default=True, + description=_('Check to enable RSS feeds') + ) +) + settings.register( BooleanValue( SOCIAL_SHARING, diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst index f5714421..0fff72a1 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 enable/disable rss feeds (Evgeny) * Added minimum reputation to insert links and hotlinked images (Evgeny) * Added minimum reputation to suggest links as plain text (Evgeny) * Added support of Haystack for search (Adolfo) diff --git a/askbot/feed.py b/askbot/feed.py index 285bb452..ac3dcdd0 100644 --- a/askbot/feed.py +++ b/askbot/feed.py @@ -18,6 +18,7 @@ from django.contrib.syndication.feeds import Feed from django.contrib.contenttypes.models import ContentType from django.utils.translation import ugettext as _ from django.core.exceptions import ObjectDoesNotExist +from django.http import Http404 from askbot.models import Post from askbot.conf import settings as askbot_settings @@ -37,6 +38,8 @@ class RssIndividualQuestionFeed(Feed): return askbot_settings.APP_DESCRIPTION def get_object(self, bits): + if askbot_settings.RSS_ENABLED is False: + raise Http404 if len(bits) != 1: raise ObjectDoesNotExist return Post.objects.get_questions().get(id__exact = bits[0]) @@ -144,6 +147,8 @@ class RssLastestQuestionsFeed(Feed): def items(self, item): """get questions for the feed """ + if askbot_settings.RSS_ENABLED is False: + raise Http404 #initial filtering qs = Post.objects.get_questions().filter(deleted=False) @@ -165,7 +170,6 @@ class RssLastestQuestionsFeed(Feed): return qs.order_by('-thread__last_activity_at')[:30] - def main(): """main function for use as a script """ diff --git a/askbot/templates/main_page/tab_bar.html b/askbot/templates/main_page/tab_bar.html index 17ab810e..37f63012 100644 --- a/askbot/templates/main_page/tab_bar.html +++ b/askbot/templates/main_page/tab_bar.html @@ -1,6 +1,7 @@ {% import "macros.html" as macros %} {% load extra_filters_jinja %} {% cache 0 "scope_sort_tabs" search_tags request.user author_name scope sort query context.page language_code %} +{% if settings.RSS_ENABLED %} {% trans %}RSS{% endtrans %} +{% endif %}
{% trans %}Sort by »{% endtrans %} diff --git a/askbot/templates/question/sidebar.html b/askbot/templates/question/sidebar.html index 4d431ef2..905ce781 100644 --- a/askbot/templates/question/sidebar.html +++ b/askbot/templates/question/sidebar.html @@ -39,12 +39,14 @@ {%endif%} + {% if settings.RSS_ENABLED %}

{% trans %}subscribe to rss feed{% endtrans %}

+ {% endif %}
-- cgit v1.2.3-1-g7c22