コード例 #1
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        g1 = ConfigurationGroup('req2', 'Requirements 2', ordering=1000)

        self.g1 = g1

        choices1 = config_register(
            MultipleStringValue(BASE_GROUP, 'rc1', ordering=1))

        self.g1c1 = config_register(
            IntegerValue(g1, 'c1', requires=choices1, ordering=3))
        self.g1c2 = config_register(
            IntegerValue(g1, 'c2', requires=choices1, ordering=4))
        self.g1c3 = config_register(IntegerValue(g1, 'c3', ordering=5))

        choices1.update('c1')

        g2 = ConfigurationGroup('req3', 'Requirements 3', ordering=1000)

        self.g2 = g2

        choices2 = config_register(
            StringValue(BASE_GROUP, 'choices2', ordering=1))

        self.g2c1 = config_register(
            IntegerValue(g2, 'c1', requires=choices2, ordering=3))
        self.g2c2 = config_register(
            IntegerValue(g2, 'c2', requires=choices2, ordering=4))
        self.g2c3 = config_register(
            IntegerValue(g2, 'c3', requires=choices2, ordering=5))

        choices2.update('c1')
コード例 #2
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        g1 = ConfigurationGroup('reqval', 'Requirements 3', ordering=1000)

        self.g1 = g1

        choices1 = config_register(MultipleStringValue(BASE_GROUP, 'valchoices', ordering=1))

        self.g1c1 = config_register(IntegerValue(g1, 'c1', requires=choices1, requiresvalue='foo', ordering=3))
        self.g1c2 = config_register(IntegerValue(g1, 'c2', requires=choices1, requiresvalue='bar', ordering=4))
        self.g1c3 = config_register(IntegerValue(g1, 'c3', ordering=5))

        choices1.update('foo')

        g2 = ConfigurationGroup('reqval2', 'Requirements 4', ordering=1000)

        self.g2 = g2

        choices2 = config_register(StringValue(BASE_GROUP, 'valchoices2', ordering=1,
            choices=(('a', 'test a'), ('b', 'test b'), ('c', 'test c'))))

        self.g2c1 = config_register(IntegerValue(g2, 'c1', requires=choices2, requiresvalue='a', ordering=3))
        self.g2c2 = config_register(IntegerValue(g2, 'c2', requires=choices2, requiresvalue='b', ordering=4))
        self.g2c3 = config_register(IntegerValue(g2, 'c3', requires=choices2, requiresvalue='c', ordering=5))

        choices2.update('a')
コード例 #3
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        g = ConfigurationGroup('modules', 'module test')
        self.g = g
        self.c = config_register(ModuleValue(g, 'test'))
コード例 #4
0
 def setUp(self):
     # clear out cache from previous runs
     keyedcache.cache_delete()
     g = ConfigurationGroup('test2', 'test2')
     self.g = g
     config_register(StringValue(g, 's1'))
     config_register(IntegerValue(g, 's2', default=10))
     config_register(IntegerValue(g, 's3', default=10))
コード例 #5
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        g = ConfigurationGroup('test3', 'test3')
        self.g = g
        c1 = config_register(BooleanValue(g, 's1', default=True))
        c2 = config_register(IntegerValue(g, 's2', default=10))
        c2.update(100)
コード例 #6
0
 def test_empty_fields(self):
     "test an empty value in the form should not raise an exception"
     # Some test features had been temporary commented out before some ..Values classes are fixed
     # because I do not want to display many old inconsistencies now. (hynekcer)
     def extract_val(content):
         regr = re.search(r'SingleItem.*value="([^"]*)"', content, flags=re.MULTILINE)
         return regr and regr.group(1) or ''  # html value
     def get_setting_like_in_db(x):
         try:
             return x.setting.value
         except SettingNotSet:
             return 'Error'
     def test_empty_value_type(value_type, protocol, reject_empty=False):
         "empty value can be accepted or rejected by validation rules"
         value = value_type(GROUP2, 'SingleItem')  # first it does it to easy get the class name
         type_name = value.__class__.__name__
         value = value_type(GROUP2, 'SingleItem', description='type %s' % type_name)
         config_register(value)
         response = self.client.get('/settings/')
         html_value = extract_val(response.content)
         # print '%s "%s"' % (type_name, html_value)
         response = self.client.post('/settings/', {'Group2__SingleItem': ''})  # See in the traceback a line one level Up
         if reject_empty:
             # option reject_empty had been tested before all Value types were fixed to be similar accepting empty value
             # this is a typical text from validation warning
             self.assertContains(response, 'Please correct the error below.')
         else:
             self.assertRedirects(response, '/settings/')
             response = self.client.get('/settings/')
             html_value = extract_val(response.content)
             # print '%s "%s" "%s" "%s"' % (type_name, html_value, value.value, get_setting_like_in_db(value))
             # self.assertNotContains(response, '<object object at 0x[0-9a-f]+>')  # rendered NOTSET = object()
             # if re.search('SingleItem.*value="', response.content):
             #    self.assertTrue(re.search('SingleItem.*value="([0.]*|\[\])"', response.content))
         protocol.add(value_type)
     #
     import re
     GROUP2 = ConfigurationGroup('Group2', 'g')
     protocol = set()
     # tested values
     test_empty_value_type(BooleanValue, protocol)
     test_empty_value_type(DecimalValue, protocol)
     test_empty_value_type(DurationValue, protocol)
     test_empty_value_type(FloatValue, protocol)
     test_empty_value_type(IntegerValue, protocol)
     test_empty_value_type(PositiveIntegerValue, protocol)
     test_empty_value_type(StringValue, protocol)
     test_empty_value_type(LongStringValue, protocol)
     test_empty_value_type(MultipleStringValue, protocol)
     test_empty_value_type(LongMultipleStringValue, protocol)
     test_empty_value_type(ModuleValue, protocol)
     test_empty_value_type(PasswordValue, protocol)
     # verify completness of the test
     classes_to_test = set(getattr(livesettings.values, k) for k in livesettings.values.__all__ if \
             not k in ('BASE_GROUP', 'ConfigurationGroup', 'Value', 'SortedDotDict', 'PercentValue'))
     self.assertEqual(protocol, classes_to_test, msg='The tested classes have been not all exactly the same as expected')
コード例 #7
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        g1 = ConfigurationGroup('m1', 'Multiple Group 1', ordering=1000)
        self.g1 = g1

        self.g1c1 = config_register(MultipleStringValue(g1,
            'c1',
            choices=((1, 'one'), (2, 'two'), (3, 'three'))))
コード例 #8
0
    def setUp(self):
        keyedcache.cache_delete()
        choices = config_register(MultipleStringValue(BASE_GROUP, 'collect', ordering=1))
        self.choices = choices

        g1 = ConfigurationGroup('coll1', 'Collection 1')
        g2 = ConfigurationGroup('coll2', 'Collection 2')
        g3 = ConfigurationGroup('coll3', 'Collection 3')

        g1c1 = config_register(StringValue(g1, 'test'))
        g1c2 = config_register(StringValue(g1, 'test1'))
        g2c1 = config_register(StringValue(g2, 'test'))
        g3c1 = config_register(StringValue(g3, 'test'))

        g1c1.update('set a')
        g1c2.update('set b')
        g2c1.update('set a')
        g3c1.update('set d')

        choices.update(['coll1', 'coll3'])
コード例 #9
0
    def testAddPreregisteredChoice(self):
        """Test that we can register choices before the config is actually set up."""
        config_add_choice('ctg1', 'c1', ('a', 'Item A'))
        config_add_choice('ctg1', 'c1', ('b', 'Item B'))
        config_add_choice('ctg1', 'c1', ('c', 'Item C'))

        g1 = ConfigurationGroup('ctg1', 'Choice 1', ordering=1000)
        config_register(StringValue(g1, 'c1'))

        c = config_get('ctg1', 'c1')

        self.assertEqual(c.choices, [('a', 'Item A'), ('b', 'Item B'), ('c', 'Item C')])
コード例 #10
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        choices1 = config_register(MultipleStringValue(BASE_GROUP, 'groupchoice', ordering=1))
        choices2 = config_register(MultipleStringValue(BASE_GROUP, 'groupchoice2', ordering=1))

        g1 = ConfigurationGroup('groupreq', 'Requirements 4', ordering=1000, requires=choices1)
        self.g1 = g1

        self.g1c1 = config_register(IntegerValue(g1, 'c1', ordering=3))
        self.g1c2 = config_register(IntegerValue(g1, 'c2', requires=choices2, requiresvalue='bar', ordering=4))
        self.g1c3 = config_register(IntegerValue(g1, 'c3', ordering=5))
コード例 #11
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        g1 = ConfigurationGroup('group1', 'Group 1', ordering=-1001)
        g2 = ConfigurationGroup('group2', 'Group 2', ordering=-1002)
        g3 = ConfigurationGroup('group3', 'Group 3', ordering=-1003)

        self.g1 = g1
        self.g2 = g2
        self.g3 = g3

        self.g1c1 = config_register(IntegerValue(g1, 'c1'))
        self.g1c2 = config_register(IntegerValue(g1, 'c2'))
        self.g1c3 = config_register(IntegerValue(g1, 'c3'))

        self.g2c1 = config_register(IntegerValue(g2, 'c1'))
        self.g2c2 = config_register(IntegerValue(g2, 'c2'))
        self.g2c3 = config_register(IntegerValue(g2, 'c3'))

        self.g3c1 = config_register(IntegerValue(g3, 'c1'))
        self.g3c2 = config_register(IntegerValue(g3, 'c2'))
        self.g3c3 = config_register(IntegerValue(g3, 'c3'))
コード例 #12
0
    def setUp(self):
        from django.contrib.auth.models import User
        from django.utils.datastructures import SortedDict
        # The following hack works like completely replaced ConfigurationSettings internal state only, if
        # no the same group name is used inside and outside the test.
        self.saved_conf_inst = ConfigurationSettings._ConfigurationSettings__instance.settings
        ConfigurationSettings.__dict__['_ConfigurationSettings__instance'].settings = SortedDict()

        keyedcache.cache_delete()
        # set new users and values
        user = User.objects.create_user('admin', '*****@*****.**', 'secret')
        user.is_superuser = True
        user.save()
        self.client.login(username='******', password='******')
        GROUP2 = ConfigurationGroup('Group2', 'g')
        value = IntegerValue(GROUP2, 'SingleItem')
        config_register(value)
コード例 #13
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        g1 = ConfigurationGroup('req1', 'Requirements 1', ordering=1000)

        self.g1 = g1

        bool1 = config_register(BooleanValue(g1, 'bool1', default=False, ordering=1))
        bool2 = config_register(BooleanValue(g1, 'bool2', ordering=2))

        self.g1c1 = config_register(IntegerValue(g1, 'c1', requires=bool1, ordering=3))

        self.g1c2 = config_register(IntegerValue(g1, 'c2', requires=bool2, ordering=4))
        self.g1c3 = config_register(IntegerValue(g1, 'c3', ordering=5))

        bool2.update(True)
コード例 #14
0
    def setUp(self):
        # clear out cache from previous runs
        keyedcache.cache_delete()

        djangosettings.LIVESETTINGS_OPTIONS = {
            1: {
                'DB': False,
                'SETTINGS': {
                    'overgroup': {
                        's2': '100',
                        'choices': '["one","two","three"]'
                    }
                }
            }
        }

        g = ConfigurationGroup('overgroup', 'Override Group')
        self.g = g
        config_register(StringValue(g, 's1'))
        config_register(IntegerValue(g, 's2', default=10))
        config_register(IntegerValue(g, 's3', default=10))
        config_register(MultipleStringValue(g, 'choices'))
コード例 #15
0
from django.utils.translation import ugettext_lazy, ugettext
from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, DecimalValue, PositiveIntegerValue
from livesettings.functions import config_register, config_register_list, config_get_group, config_choice_values, config_value
from payment import signals, active_gateways
from satchmo_utils import is_string_like
import logging

_ = ugettext_lazy

log = logging.getLogger('payment.config')

PAYMENT_GROUP = ConfigurationGroup('PAYMENT', _('Payment Settings'))

CRON_KEY = config_register(
    StringValue(
        PAYMENT_GROUP,
        'CRON_KEY',
        description=_("Cron Passkey"),
        help_text=
        _("Enter an authentication passkey to secure your recurring billing cron url."
          ),
        default="x1234replace_me"))

ALLOW_URL_CRON = config_register(
    BooleanValue(
        PAYMENT_GROUP,
        'ALLOW_URL_REBILL',
        description=_("Allow URL Access to Cron for subscription rebills"),
        help_text=_(
            "Do you want to allow remote url calls for subscription billing?"),
        default=False))
コード例 #16
0
 def testSetGroup(self):
     g1 = ConfigurationGroup('test1', 'test1')
     value = IntegerValue(g1, 'SingleGroupedItem')
     config_register(value)
     self.assertFalse(config_exists(BASE_GROUP, 'SingleGroupedItem'))
     self.assert_(config_exists(g1, 'SingleGroupedItem'))
コード例 #17
0
from livesettings.functions import config_register_list
from livesettings.values import ConfigurationGroup, StringValue, BooleanValue, \
    ModuleValue
from django.utils.translation import ugettext_lazy as _

PAYMENT_GROUP = ConfigurationGroup('PAYMENT_CONCARDIS',
                                   _('Concardis Payment Module Settings'),
                                   ordering=101)

config_register_list(
    StringValue(PAYMENT_GROUP,
                'CURRENCY_CODE',
                description=_('Currency Code'),
                help_text=_('Currency code for Concardis transactions.'),
                default='EUR'),
    StringValue(
        PAYMENT_GROUP,
        'SHA_IN_PASSPHRASE',
        description=_('SHA-IN pass phrase'),
        help_text=_('The SHA-IN pass phrase used to hash the parameters.'),
        default=''),
    StringValue(
        PAYMENT_GROUP,
        'SHA_OUT_PASSPHRASE',
        description=_('SHA-OUT pass phrase'),
        help_text=_('The SHA-OUT pass phrase used to hash the parameters.'),
        default=''),
    StringValue(
        PAYMENT_GROUP,
        'POST_URL',
        description=_('Post URL'),
コード例 #18
0
"""
Settings for reputation changes that apply to
user in response to various actions by the same
users or others
"""
from django.utils.translation import ugettext_lazy as _
from askbot.conf.settings_wrapper import settings
from livesettings.values import ConfigurationGroup, IntegerValue
from askbot.conf.super_groups import REP_AND_BADGES

REP_CHANGES = ConfigurationGroup('REP_CHANGES',
                                 _('Karma loss and gain rules'),
                                 super_group=REP_AND_BADGES,
                                 ordering=2)

settings.register(
    IntegerValue(REP_CHANGES,
                 'MAX_REP_GAIN_PER_USER_PER_DAY',
                 default=200,
                 description=_('Maximum daily reputation gain per user')))

settings.register(
    IntegerValue(REP_CHANGES,
                 'REP_GAIN_FOR_RECEIVING_UPVOTE',
                 default=10,
                 description=_('Gain for receiving an upvote')))

settings.register(
    IntegerValue(REP_CHANGES,
                 'REP_GAIN_FOR_RECEIVING_ANSWER_ACCEPTANCE',
                 default=15,
コード例 #19
0
ファイル: config.py プロジェクト: siddhant3030/Satchmo
pip install fedex
pip install suds

All values based on July 2011 Fedex Developer Guide
"""

from django.utils.translation import ugettext_lazy as _
from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, MultipleStringValue
from livesettings.functions import config_register_list, config_get
SHIP_MODULES = config_get('SHIPPING', 'MODULES')
SHIP_MODULES.add_choice(
    ('shipping.modules.fedex_web_services', 'FEDEX (fedex_web_services)'))

SHIPPING_GROUP = ConfigurationGroup(
    'shipping.modules.fedex_web_services',
    _('FedEx Web Services Shipping Settings'),
    requires=SHIP_MODULES,
    requiresvalue='shipping.modules.fedex_web_services',
    ordering=101)

config_register_list(
    StringValue(SHIPPING_GROUP,
                'METER_NUMBER',
                description=_('FedEx Meter Number'),
                help_text=_('Meter Number provided by FedEx.'),
                default=''),
    StringValue(SHIPPING_GROUP,
                'ACCOUNT',
                description=_('FedEx Account Number'),
                help_text=_('FedEx Account Number.'),
                default=''),
    StringValue(SHIPPING_GROUP,
コード例 #20
0
        return new_value

    if new_value:
        for key, value in list(LARGE_SITE_MODE_SETTINGS.items()):
            settings.update(key, value)

    else:
        for key in LARGE_SITE_MODE_SETTINGS:
            settings.reset(key)

    return new_value


SITE_MODES = ConfigurationGroup(
    'SITE_MODES',
    _('Bootstrap mode'),
    super_group=REP_AND_BADGES
)

settings.register(
    BooleanValue(
        SITE_MODES,
        'ACTIVATE_LARGE_SITE_MODE',
        default=False,
        description=_('Activate a "Large site" mode'),
        help_text=_(
            "\"Large site\" mode increases reputation and certain badge "
            "thresholds, to values, more suitable for the larger communities, "
            "<strong>WARNING:</strong> your current values for "
            "Minimum reputation, Badge Settings and Vote Rules will "
            "be changed after you modify this setting."
コード例 #21
0
"""
Sidebar settings
"""
from django.utils.translation import ugettext_lazy as _
from askbot.conf.settings_wrapper import settings
from livesettings.values import ConfigurationGroup
from livesettings import values
from askbot.conf.super_groups import CONTENT_AND_UI

SIDEBAR_PROFILE = ConfigurationGroup('SIDEBAR_PROFILE',
                                     _('User profile sidebar'),
                                     super_group=CONTENT_AND_UI)

settings.register(
    values.LongStringValue(
        SIDEBAR_PROFILE,
        'SIDEBAR_PROFILE',
        description=_('Custom sidebar'),
        default='',
        localized=True,
        help_text=_(
            'Use this area to enter content at the TOP of the sidebar in HTML '
            'format. When using this option (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.BooleanValue(
        SIDEBAR_PROFILE,
        'SIDEBAR_PROFILE_ANON_ONLY',
        description=_('Show the text entered above only to anonymous users'),
コード例 #22
0
ファイル: config.py プロジェクト: siddhant3030/Satchmo
from decimal import Decimal
from django.utils.translation import ugettext_lazy as _
from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, DecimalValue, MultipleStringValue
from livesettings.functions import config_register_list, config_get

SHIP_MODULES = config_get('SHIPPING', 'MODULES')
SHIP_MODULES.add_choice(('shipping.modules.usps', 'USPS'))

SHIPPING_GROUP = ConfigurationGroup('shipping.modules.usps',
                                    _('U.S.P.S. Shipping Settings'),
                                    requires=SHIP_MODULES,
                                    ordering=101)

config_register_list(
    StringValue(SHIPPING_GROUP,
                'USER_ID',
                description=_("USPS  Username"),
                help_text=_("User ID provided by USPS site."),
                default=""),
    StringValue(SHIPPING_GROUP,
                'USER_PASSWORD',
                description=_("USPS Password"),
                help_text=_("User password provided by USPS site."),
                default=""),
    DecimalValue(
        SHIPPING_GROUP,
        'HANDLING_FEE',
        description=_("Handling Fee"),
        help_text=_("The cost of packaging and taking order to post office"),
        default=Decimal('0.00')),
    MultipleStringValue(
コード例 #23
0
'''
Canada Post Shipping Module
v0.1.1
'''
from django.utils.translation import ugettext_lazy as _
from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, MultipleStringValue
from livesettings.functions import config_register_list, config_get

SHIP_MODULES = config_get('SHIPPING', 'MODULES')
SHIP_MODULES.add_choice(('shipping.modules.canadapost', 'Canada Post'))

SHIPPING_GROUP = ConfigurationGroup(
    'shipping.modules.canadapost',
    _('Canada Post Shipping Settings'),
    requires=SHIP_MODULES,
    requiresvalue='shipping.modules.canadapost',
    ordering=101)

config_register_list(
    StringValue(SHIPPING_GROUP,
                'CPCID',
                description=_('Canada Post Merchant ID'),
                help_text=_('The merchant ID assigned by Canada Post'),
                default='CPC_DEMO_XML'),

    #http://sellonline.canadapost.ca/DevelopersResources/protocolV3/ProductID.html
    MultipleStringValue(
        SHIPPING_GROUP,
        'CANADAPOST_SHIPPING_CHOICES',
        description=_("Canada Post shipping choices available to customers."),
        choices=(
コード例 #24
0
# -*- coding: utf-8 -*-

import os
import sys
from six.moves import urllib
from decimal import Decimal
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from livesettings.functions import config_register
from livesettings.values import BooleanValue, StringValue, ConfigurationGroup, PositiveIntegerValue, DecimalValue

SHOP_GROUP = ConfigurationGroup('SHOP', _('Satchmo Shop Settings'), ordering=0)

project_root = os.path.dirname(
    os.path.normpath(
        sys.modules[os.environ['DJANGO_SETTINGS_MODULE']].__file__))
# default value `project_root + 'static'` is currently the best common for all Django 1.2 - 1.4
default_icon_url = urllib.parse.urlunsplit(
    ('file', '', os.path.join(project_root, 'static',
                              'images/sample-logo.bmp'), '', ''))

#### SHOP Group ####

LOGO_URI = config_register(
    StringValue(SHOP_GROUP,
                'LOGO_URI',
                description=_("URI to the logo for the store"),
                help_text=_(
                    ("For example http://www.example.com/images/logo.jpg or "
                     "file:///var/www/html/images/logo.jpg")),
                default=default_icon_url))
コード例 #25
0
ファイル: config.py プロジェクト: siddhant3030/Satchmo
from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, DecimalValue, PositiveIntegerValue, ModuleValue, MultipleStringValue, LongStringValue
from livesettings.functions import config_register_list
from django.utils.translation import ugettext_lazy as _

# this is so that the translation utility will pick up the string
gettext = lambda s: s

PAYMENT_GROUP = ConfigurationGroup('PAYMENT_DUMMY',
                                   _('Payment Test Module Settings'),
                                   ordering=100)

config_register_list(
    BooleanValue(PAYMENT_GROUP,
                 'LIVE',
                 description=_("Accept real payments"),
                 help_text=_("False if you want to be in test mode"),
                 default=False),
    ModuleValue(PAYMENT_GROUP,
                'MODULE',
                description=_('Implementation module'),
                hidden=True,
                default='payment.modules.dummy'),
    StringValue(PAYMENT_GROUP,
                'KEY',
                description=_("Module key"),
                hidden=True,
                default='DUMMY'),
    StringValue(
        PAYMENT_GROUP,
        'LABEL',
        description=_('English name for this group on the checkout screens'),
コード例 #26
0
"""
Sidebar settings
"""
from django.utils.translation import ugettext_lazy as _
from askbot.conf.settings_wrapper import settings
from livesettings.values import ConfigurationGroup
from livesettings import values
from askbot.conf.super_groups import CONTENT_AND_UI

LEADING_SIDEBAR = ConfigurationGroup(
    'LEADING_SIDEBAR',
    _('Common left sidebar'),
    super_group=CONTENT_AND_UI
)

settings.register(
    values.BooleanValue(
        LEADING_SIDEBAR,
        'ENABLE_LEADING_SIDEBAR',
        description=_('Enable left sidebar'),
        default=False,
    )
)

settings.register(
    values.LongStringValue(
        LEADING_SIDEBAR,
        'LEADING_SIDEBAR',
        description=_('HTML for the left sidebar'),
        default='',
        help_text=_(
コード例 #27
0
from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, DecimalValue, PositiveIntegerValue, ModuleValue, MultipleStringValue, LongStringValue
from livesettings.functions import config_register_list
from django.utils.translation import ugettext_lazy as _

PAYMENT_GROUP = ConfigurationGroup('PAYMENT_GIFTCERTIFICATE',
                                   _('Gift Certificate Settings'))

config_register_list(
    StringValue(
        PAYMENT_GROUP,
        'CHARSET',
        description=_("Character Set"),
        default="BCDFGHKPRSTVWXYZbcdfghkprstvwxyz23456789",
        help_text=
        _("The characters allowable in randomly-generated certficate codes.  No vowels means no unfortunate words."
          )),
    StringValue(PAYMENT_GROUP,
                'KEY',
                description=_("Module key"),
                hidden=True,
                default='GIFTCERTIFICATE'),
    StringValue(
        PAYMENT_GROUP,
        'FORMAT',
        description=_('Code format'),
        default="^^^^-^^^^-^^^^",
        help_text=
        _("Enter the format for your cert code.  Use a '^' for the location of a randomly generated character."
          )),
    ModuleValue(PAYMENT_GROUP,
                'MODULE',
コード例 #28
0
from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, ModuleValue, MultipleStringValue
from livesettings.functions import config_register_list
from django.utils.translation import ugettext_lazy as _

# this is so that the translation utility will pick up the string
gettext = lambda s: s
_strings = (gettext('CreditCard'), gettext('Credit Card'),
            gettext('Sage Pay Secure Payments'))

# These cards require the issue number and start date fields filled in.
REQUIRES_ISSUE_NUMBER = ('MAESTRO', 'SOLO')

PAYMENT_GROUP = ConfigurationGroup('PAYMENT_SAGEPAY',
                                   _('Sage Pay Payment Settings'),
                                   ordering=101)

config_register_list(
    BooleanValue(PAYMENT_GROUP,
                 'LIVE',
                 description=_("Accept real payments"),
                 help_text=_("False if you want to be in test mode"),
                 default=False),
    BooleanValue(PAYMENT_GROUP,
                 'SIMULATOR',
                 description=_("Simulated Transactions?"),
                 help_text=_("Must be false to accept real payments"),
                 default=False),
    BooleanValue(
        PAYMENT_GROUP,
        'SKIP_POST',
        description=_("Skip post?"),
コード例 #29
0
"""Settings to control content moderation"""

from django.utils.translation import ugettext_lazy as _
from askbot.conf.settings_wrapper import settings
from askbot.conf.super_groups import DATA_AND_FORMATTING
from livesettings.values import ConfigurationGroup
from livesettings.values import BooleanValue
from livesettings.values import LongStringValue
from livesettings.values import StringValue

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

CONTENT_MODERATION_MODE_CHOICES = (
    ('flags', _('audit flagged posts')),
    ('audit', _('audit flagged posts and watched users')),
    ('premoderation', _('pre-moderate watched users and audit flagged posts')),
)

settings.register(
    StringValue(
        MODERATION,
        'CONTENT_MODERATION_MODE',
        choices=CONTENT_MODERATION_MODE_CHOICES,
        default='flags',
        description=_('Content moderation method'),
        help_text=_(
            "Audit is made after the posts are published, pre-moderation "
            "prevents publishing before moderator's decision.")))
コード例 #30
0
"""
Social sharing settings
"""
from django.utils.translation import ugettext_lazy as _
from askbot.conf.settings_wrapper import settings
from askbot.conf.super_groups import EXTERNAL_SERVICES
from livesettings.values import ConfigurationGroup, BooleanValue, \
    StringValue

SOCIAL_SHARING = ConfigurationGroup('SOCIAL_SHARING',
                                    _('Content sharing'),
                                    super_group=EXTERNAL_SERVICES)

settings.register(
    BooleanValue(SOCIAL_SHARING,
                 'RSS_ENABLED',
                 default=True,
                 description=_('Check to enable RSS feeds')))

settings.register(
    StringValue(SOCIAL_SHARING,
                'SHARING_SUFFIX_TEXT',
                default='',
                description=_('Hashtag or suffix to sharing messages')))

settings.register(
    BooleanValue(
        SOCIAL_SHARING,
        'ENABLE_SHARING_TWITTER',
        default=True,
        description=_('Check to enable sharing of questions on Twitter'),