diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-03-22 00:10:30 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-03-22 00:10:30 -0400 |
commit | df2a120b28c74e3e85819294d0652759f6194af9 (patch) | |
tree | d8f962aecdb1e81f796695e6232183bb3f1f0e43 /askbot/conf | |
parent | db7fdd122616d527f62747738c4225b03a69ab09 (diff) | |
download | askbot-df2a120b28c74e3e85819294d0652759f6194af9.tar.gz askbot-df2a120b28c74e3e85819294d0652759f6194af9.tar.bz2 askbot-df2a120b28c74e3e85819294d0652759f6194af9.zip |
allowed to enable and disable scopes on the main page
Diffstat (limited to 'askbot/conf')
-rw-r--r-- | askbot/conf/__init__.py | 1 | ||||
-rw-r--r-- | askbot/conf/main_pages.py | 83 |
2 files changed, 84 insertions, 0 deletions
diff --git a/askbot/conf/__init__.py b/askbot/conf/__init__.py index fd62bc88..c1989f8d 100644 --- a/askbot/conf/__init__.py +++ b/askbot/conf/__init__.py @@ -8,6 +8,7 @@ import askbot.conf.karma_and_badges_visibility import askbot.conf.email import askbot.conf.forum_data_rules import askbot.conf.moderation +import askbot.conf.main_pages import askbot.conf.flatpages import askbot.conf.site_settings import askbot.conf.license diff --git a/askbot/conf/main_pages.py b/askbot/conf/main_pages.py new file mode 100644 index 00000000..940d2e91 --- /dev/null +++ b/askbot/conf/main_pages.py @@ -0,0 +1,83 @@ +""" +Settings responsible for display of questions lists +""" +from askbot.conf.settings_wrapper import settings +from askbot.conf.super_groups import DATA_AND_FORMATTING +from askbot.deps import livesettings +from django.utils.translation import ugettext_lazy as _ + +MAIN_PAGES = livesettings.ConfigurationGroup( + 'MAIN_PAGES', + _('Logic of the questions page'), + super_group=DATA_AND_FORMATTING + ) + +settings.register( + livesettings.BooleanValue( + MAIN_PAGES, + 'ALL_SCOPE_ENABLED', + default=True, + description=_('Enable "All Questions" selector'), + help_text=_('At least one of these selectors must be enabled') + ) +) + +settings.register( + livesettings.BooleanValue( + MAIN_PAGES, + 'UNANSWERED_SCOPE_ENABLED', + default=True, + description=_('Enable "Unanswered Questions" selector'), + help_text=_('At least one of these selectors must be enabled') + ) +) + +settings.register( + livesettings.BooleanValue( + MAIN_PAGES, + 'FOLLOWED_SCOPE_ENABLED', + default=True, + description=_('Enable "Followed Questions" selector'), + help_text=_('At least one of these selectors must be enabled') + ) +) + +def enable_default_selector_if_disabled(old_value, new_value): + scope_switch_name = new_value.upper() + '_SCOPE_ENABLED' + is_enabled = getattr(settings, scope_switch_name) + if is_enabled is False: + settings.update(scope_switch_name, True) + return new_value + +SCOPE_CHOICES_AUTHENTICATED = ( + ('all', _('All Questions')), + ('unanswered', _('Unanswered Questions')), + ('followed', _('Followed Questions')) +) + +settings.register( + livesettings.StringValue( + MAIN_PAGES, + 'DEFAULT_SCOPE_AUTHENTICATED', + choices=SCOPE_CHOICES_AUTHENTICATED, + default='all', + description=_('Default questions selector for the authenticated users'), + update_callback=enable_default_selector_if_disabled + ) +) + +SCOPE_CHOICES_ANONYMOUS = (#anonymous users can't see followed questions + ('all', _('All Questions')), + ('unanswered', _('Unanswered Questions')), +) + +settings.register( + livesettings.StringValue( + MAIN_PAGES, + 'DEFAULT_SCOPE_ANONYMOUS', + choices=SCOPE_CHOICES_ANONYMOUS, + default='all', + description=_('Default questions selector for the anonymous users'), + update_callback=enable_default_selector_if_disabled + ) +) |