1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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 _
QUESTION_LISTS = livesettings.ConfigurationGroup(
'QUESTION_LISTS',
_('Listings of questions'),
super_group=DATA_AND_FORMATTING
)
settings.register(
livesettings.BooleanValue(
QUESTION_LISTS,
'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(
QUESTION_LISTS,
'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(
QUESTION_LISTS,
'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(
QUESTION_LISTS,
'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(
QUESTION_LISTS,
'DEFAULT_SCOPE_ANONYMOUS',
choices=SCOPE_CHOICES_ANONYMOUS,
default='all',
description=_('Default questions selector for the anonymous users'),
update_callback=enable_default_selector_if_disabled
)
)
|