summaryrefslogtreecommitdiffstats
path: root/askbot/conf/moderation.py
blob: b537663f396369651cf682361fd1c0a793baf5e8 (plain)
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
"""Settings to control content moderation"""

from askbot.conf.settings_wrapper import settings
from askbot.conf.super_groups import DATA_AND_FORMATTING
from askbot.deps.livesettings import ConfigurationGroup
from askbot.deps.livesettings import BooleanValue
from django.core.cache import cache
from django.utils.translation import ugettext_lazy as _

def empty_cache_callback(old_value, new_value):
    """used to clear cache on change of certain values"""
    if old_value != new_value:
        #todo: change this to warmup cache
        cache.clear()
    return new_value

MODERATION = ConfigurationGroup(
                    'MODERATION',
                    _('Content moderation'),
                    super_group = DATA_AND_FORMATTING
                )

settings.register(
    BooleanValue(
        MODERATION,
        'ENABLE_CONTENT_MODERATION',
        default = False,
        description = _('Enable content moderation'),
        update_callback = empty_cache_callback
    )
)

settings.register(
    BooleanValue(
        MODERATION,
        'ENABLE_TAG_MODERATION',
        default = False,
        description = _('Enable tag moderation'),
        help_text = _(
            'If enabled, any new tags will not be applied '
            'to the questions, but emailed to the moderators. '
            'To use this feature, tags must be optional.'
        )
    )
)