Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    def setUp(self):
        from django.contrib.auth.models import Permission, User
        from django.contrib.contenttypes.models import ContentType
        # Users with different permissions
        # staff member
        user1 = User.objects.create_user('warehouseman', '*****@*****.**',
                                         'secret')
        user1.is_staff = True
        user1.save()
        # developper with limited permissions
        user2 = User.objects.create_user('cautious_developer',
                                         '*****@*****.**', 'secret')
        user2.is_staff = True
        user2.user_permissions.add(Permission.objects.get(codename='change_setting', \
                content_type=ContentType.objects.get(app_label='livesettings', model='setting')))
        user2.save()
        # superuser
        user3 = User.objects.create_user('superuser', '*****@*****.**',
                                         'secret')
        user3.is_superuser = True
        user3.save()

        keyedcache.cache_delete()
        # Example config
        config_register(IntegerValue(BASE_GROUP, 'SingleItem', default=0))
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def test_export(self):
     "Details of exported settings"
     self.client.login(username='******', password='******')
     val2 = IntegerValue(BASE_GROUP, 'ModifiedItem', default=0)
     config_register(val2)
     val2.update(6789)
     response = self.client.get('/settings/export/')
     self.assertContains(response, "LIVESETTINGS_OPTIONS =", 1)
     self.assertContains(response, "'DB': False", 1)
     self.assertContains(response, "'BASE':", 1)
     self.assertContains(response, "'ModifiedItem': '6789'", 1)
Ejemplo n.º 6
0
 def test_export(self):
     "Details of exported settings"
     self.client.login(username='******', password='******')
     val2 = IntegerValue(BASE_GROUP, 'ModifiedItem', default=0)
     config_register(val2)
     val2.update(6789)
     response = self.client.get('/settings/export/')
     self.assertContains(response, "LIVESETTINGS_OPTIONS =", 1)
     self.assertContains(response, "'DB': False", 1)
     self.assertContains(response, "u'BASE':", 1)
     self.assertContains(response, "u'ModifiedItem': u'6789'", 1)
Ejemplo n.º 7
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')])
Ejemplo n.º 8
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')])
Ejemplo n.º 9
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))
Ejemplo n.º 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))
Ejemplo n.º 11
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')
Ejemplo n.º 12
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')
Ejemplo n.º 13
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')
Ejemplo n.º 14
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')
Ejemplo n.º 15
0
 def test_secret_password(self):
     "Verify that password is saved but not re-echoed if render_value=False"
     # example of value, where reading is more sensitive than writing
     val1 = PasswordValue(BASE_GROUP, 'password_to_reading_external_payment_gateway', render_value=False)
     config_register(val1)
     val1.update('secret')
     val2 = PasswordValue(BASE_GROUP, 'unsecure_password')
     config_register(val2)
     val2.update('unsecure_pwd')
     self.client.login(username='******', password='******')
     response = self.client.get('/settings/')
     self.assertContains(response, 'password_to_reading_external_payment_gateway')
     self.assertNotContains(response, 'secret')
     self.assertContains(response, 'unsecure_password')
     self.assertContains(response, 'unsecure_pwd')
Ejemplo n.º 16
0
 def test_secret_password(self):
     "Verify that password is saved but not re-echoed if render_value=False"
     # example of value, where reading is more sensitive than writing
     val1 = PasswordValue(BASE_GROUP, 'password_to_reading_external_payment_gateway', render_value=False)
     config_register(val1)
     val1.update('secret')
     val2 = PasswordValue(BASE_GROUP, 'unsecure_password')
     config_register(val2)
     val2.update('unsecure_pwd')
     self.client.login(username='******', password='******')
     response = self.client.get('/settings/')
     self.assertContains(response, 'password_to_reading_external_payment_gateway')
     self.assertNotContains(response, 'secret')
     self.assertContains(response, 'unsecure_password')
     self.assertContains(response, 'unsecure_pwd')
Ejemplo n.º 17
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'))
Ejemplo n.º 18
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'))
Ejemplo n.º 19
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)
Ejemplo n.º 20
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)
Ejemplo n.º 21
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)
Ejemplo n.º 22
0
    def setUp(self):
        from django.contrib.auth.models import User
        from collections import OrderedDict
        # 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 = OrderedDict()

        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)
Ejemplo n.º 23
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'))))
Ejemplo n.º 24
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'))))
Ejemplo n.º 25
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'])
Ejemplo n.º 26
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'])
Ejemplo n.º 27
0
    def setUp(self):
        from django.contrib.auth.models import Permission, User
        from django.contrib.contenttypes.models import ContentType
        # Users with different permissions
        # staff member
        user1 = User.objects.create_user('warehouseman', '*****@*****.**', 'secret')
        user1.is_staff = True
        user1.save()
        # developper with limited permissions
        user2 = User.objects.create_user('cautious_developer', '*****@*****.**', 'secret')
        user2.is_staff = True
        user2.user_permissions.add(Permission.objects.get(codename='change_setting', \
                content_type=ContentType.objects.get(app_label='livesettings', model='setting')))
        user2.save()
        # superuser
        user3 = User.objects.create_user('superuser', '*****@*****.**', 'secret')
        user3.is_superuser = True
        user3.save()

        keyedcache.cache_delete()
        # Example config
        config_register(IntegerValue(BASE_GROUP, 'SingleItem', default=0))
Ejemplo n.º 28
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))
Ejemplo n.º 29
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))
Ejemplo n.º 30
0
 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)
Ejemplo n.º 31
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'))
Ejemplo n.º 32
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'))
Ejemplo n.º 33
0
    def register(self, value):
        """registers the setting
        value must be a subclass of askbot.deps.livesettings.Value
        """
        key = value.key
        group_key = value.group.key

        ordering = self.__ordering_index.get(group_key, None)
        if ordering:
            ordering += 1
            value.ordering = ordering
        else:
            ordering = 1
            value.ordering = ordering
        self.__ordering_index[group_key] = ordering

        if key not in self.__instance:
            self.__instance[key] = config_register(value)
            self.__group_map[key] = group_key
Ejemplo n.º 34
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'))
Ejemplo n.º 35
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'))
Ejemplo n.º 36
0
"""Adds Configuration-module specific configuration options"""

from django.utils.translation import ugettext_lazy as _
from livesettings.functions import config_register
from livesettings.values import BooleanValue
from product.config import PRODUCT_GROUP

config_register(
    BooleanValue(
        PRODUCT_GROUP,
        'SEARCH_SHOW_PRODUCTVARIATIONS',
        description=_("Show product variations in search results?"),
        help_text=_(
            "If yes, the product variations will show up in searches."),
        default=True))
Ejemplo n.º 37
0
from livesettings.values import StringValue, ConfigurationGroup, BooleanValue, MultipleStringValue
from livesettings.functions import config_register, config_value
from satchmo_store.shop import get_satchmo_setting
from satchmo_utils import load_module
import logging

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

SHIPPING_GROUP = ConfigurationGroup('SHIPPING', _('Shipping Settings'))

SHIPPING_ACTIVE = config_register(
    MultipleStringValue(
        SHIPPING_GROUP,
        'MODULES',
        description=_("Active shipping modules"),
        help_text=
        _("Select the active shipping modules, save and reload to set any module-specific shipping settings."
          ),
        default=["shipping.modules.per"],
        choices=[('shipping.modules.per', _('Per piece'))],
        ordering=0))

config_register(
    StringValue(
        SHIPPING_GROUP,
        'HIDING',
        description=_("Hide if one?"),
        help_text=_(
            "Hide shipping form fields if there is only one choice available?"
        ),
        default='NO',
Ejemplo n.º 38
0
from livesettings.functions import config_register
from livesettings.values import StringValue, IntegerValue, BooleanValue, MultipleStringValue
from satchmo_store.shop.config import SHOP_GROUP

from django.utils.translation import ugettext_lazy as _

config_register(
    BooleanValue(SHOP_GROUP,
    'AUTHENTICATION_REQUIRED',
    description=_("Only authenticated users can check out"),
    help_text=_("Users will be required to authenticate (and create an account if neccessary) before checkout."),
    default=False,
    )
)

config_register(
    MultipleStringValue(SHOP_GROUP,
    'REQUIRED_BILLING_DATA',
    description=_("Required billing data"),
    help_text=_(
        "Users may be required to provide some set of billing address. Other fields are optional. "
        "You may shorten the checkout process here, but be careful, as this may leave you orders "
        "with almost no customer data! Some payment modules may override this setting."
        ),
    default=('email', 'first_name', 'last_name', 'phone', 'street1', 'city', 'postal_code', 'country'),
    choices=(
        ('email', _("Email")),
        ('title', _("Title")),
        ('first_name', _("First name")),
        ('last_name', _("Last name")),
        ('phone', _("Phone")),
Ejemplo n.º 39
0
"""Adds Configuration-module specific configuration options"""

from django.utils.translation import ugettext_lazy as _
from livesettings.values import BooleanValue
from livesettings.functions import config_register
from product.config import PRODUCT_GROUP

config_register(
    BooleanValue(PRODUCT_GROUP,
        'SEARCH_SHOW_PRODUCTVARIATIONS',
        description=_("Show product variations in search results?"),
        help_text=_("If yes, the product variations will show up in searches."),
        default=True
    ))
Ejemplo n.º 40
0
# -*- coding: utf-8 -*-

from django.utils.translation import ugettext_lazy as _
from livesettings.values import ConfigurationGroup, StringValue
from livesettings.functions import config_register

PRODUCT_GROUP = ConfigurationGroup('PRODUCT', _('Product Settings'))

config_register(
    StringValue(PRODUCT_GROUP,
        'PROTECTED_DIR',
        description=_("Protected dir"),
        help_text=_("""This is only used if you use Downloadable Products.
This value will be appended to MEDIA_ROOT/MEDIA_URL.  Do not worry about slashes.
We can handle it any which way."""),
        default="protected",
    ))
Ejemplo n.º 41
0
 def setUp(self):
     keyedcache.cache_delete()
     wide = config_register(
         LongStringValue(BASE_GROUP, 'LONG', ordering=1, default="woot"))
     self.wide = wide
     self.wide.update('*' * 1000)
Ejemplo n.º 42
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'))
Ejemplo n.º 43
0
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from livesettings.values import StringValue,ConfigurationGroup,BooleanValue
from livesettings.functions import config_register
from satchmo_utils import is_string_like, load_module
from satchmo_store.shop import get_satchmo_setting

TAX_GROUP = ConfigurationGroup('TAX', _('Tax Settings'))
TAX_MODULE = config_register(StringValue(TAX_GROUP,
    'MODULE',
    description=_("Active tax module"),
    help_text=_("Select a module, save and reload to set any module-specific settings."),
    default="tax.modules.no",
    choices=[('tax.modules.no', _('No Tax')),
    ]
))

DEFAULT_VIEW_TAX = config_register(BooleanValue(TAX_GROUP,
    'DEFAULT_VIEW_TAX',
    description=_("Show with tax included"),
    help_text=_("If yes, then all products and the cart will display with tax included."),
    default=False
))

PRODUCTS_TAXABLE_BY_DEFAULT = config_register(BooleanValue(TAX_GROUP,
    'PRODUCTS_TAXABLE_BY_DEFAULT',
    description=_("New products are automatically made taxable"),
    help_text=_("Whether newly created products should be taxable by default."),
    default=False
))
Ejemplo n.º 44
0
# -*- coding: utf-8 -*-

from django.utils.translation import ugettext_lazy as _
from livesettings.values import ConfigurationGroup, PositiveIntegerValue, MultipleStringValue, StringValue, BooleanValue
from livesettings.functions import config_register, config_register_list

PRODUCT_GROUP = ConfigurationGroup('PRODUCT', _('Product Settings'))

config_register(
    StringValue(PRODUCT_GROUP,
        'IMAGE_DIR',
        description=_("Upload Image Dir"),
        help_text=_("""Directory name for storing uploaded images.
    This value will be appended to MEDIA_ROOT.  Do not worry about slashes.
    We can handle it any which way."""),
        default="images")
)

config_register_list(
    PositiveIntegerValue(PRODUCT_GROUP,
        'NUM_DISPLAY',
        description=_("Total featured"),
        help_text=_("Total number of featured items to display"),
        default=20
    ),

    PositiveIntegerValue(PRODUCT_GROUP,
        'NUM_PAGINATED',
        description=_("Number featured"),
        help_text=_("Number of featured items to display on each page"),
        default=10
Ejemplo n.º 45
0
from django.utils.translation import ugettext_lazy as _
from livesettings.functions import config_register, config_register_list, config_get
from livesettings.values import *

# Default values should be specified explicitely, otherwise it would be
# an error if nothing is saved in the database and no default is found.

# First, setup a group to hold all our possible configs
MYAPP_GROUP = ConfigurationGroup('MyApp', _('My App Settings'), ordering=0)

# Now, add our number of images to display value
# If a user doesn't enter a value, default to 5
config_register(
    PositiveIntegerValue(
        MYAPP_GROUP,
        'NUM_IMAGES',
        description=_('Number of images to display'),
        help_text=_("How many images to display on front page."),
        # if no help_text is given, Default falue is displayed
        default=5))

# Another example of allowing the user to select from several values
config_register(
    MultipleStringValue(MYAPP_GROUP,
                        'MEASUREMENT_SYSTEM',
                        description=_("Measurement System"),
                        help_text=_("Default measurement system to use."),
                        choices=[('metric', _('Metric')),
                                 ('imperial', _('Imperial'))],
                        default="imperial"))

# Because we did not used "ordering" for values, all inputs are sorted alphabetically by name
Ejemplo n.º 46
0
 def testSetSingleConfigItem(self):
     value = IntegerValue(BASE_GROUP, 'SingleItem')
     config_register(value)
     self.assertTrue(config_exists(BASE_GROUP, 'SingleItem'))
Ejemplo n.º 47
0
    BooleanValue(PAYMENT_GROUP,
        'CAPTURE',
        description=_('Capture Payment immediately?'),
        default=True,
        help_text=_('IMPORTANT: If false, a capture attempt will be made when the order is marked as shipped.')),

    BooleanValue(PAYMENT_GROUP,
        'EXTRA_LOGGING',
        description=_("Verbose logs"),
        help_text=_("Add extensive logs during post."),
        default=False)
)

ARB_ENABLED = config_register(
    BooleanValue(PAYMENT_GROUP,
        'ARB',
        description=_('Enable ARB?'),
        default=False,
        help_text=_('Enable ARB processing for setting up subscriptions.  You must have this enabled in your Authorize account for it to work.')))

config_register(
    StringValue(PAYMENT_GROUP,
        'ARB_CONNECTION',
        description=_("Submit to URL (ARB)"),
        help_text=_("""This is the address to submit live transactions for ARB."""),
        requires=ARB_ENABLED,
        default='https://api.authorize.net/xml/v1/request.api'))

config_register(
    StringValue(PAYMENT_GROUP,
        'ARB_CONNECTION_TEST',
        description=_("Submit to Test URL (ARB)"),
Ejemplo n.º 48
0
from django.utils.translation import ugettext_lazy as _
from livesettings.values import StringValue,ConfigurationGroup, BooleanValue, MultipleStringValue
from livesettings.functions import config_register, config_value
from satchmo_store.shop import get_satchmo_setting
from satchmo_utils import load_module
import logging

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

SHIPPING_GROUP = ConfigurationGroup('SHIPPING', _('Shipping Settings'))

SHIPPING_ACTIVE = config_register(MultipleStringValue(SHIPPING_GROUP,
    'MODULES',
    description=_("Active shipping modules"),
    help_text=_("Select the active shipping modules, save and reload to set any module-specific shipping settings."),
    default=["shipping.modules.per"],
    choices=[('shipping.modules.per', _('Per piece'))],
    ordering=0
    ))

config_register(
    StringValue(SHIPPING_GROUP,
        'HIDING',
        description = _("Hide if one?"),
        help_text = _("Hide shipping form fields if there is only one choice available?"),
        default='NO',
        ordering=10,
        choices = (
            ('NO', _('No')),
            ('YES', _('Yes')),
            ('DESCRIPTION', _('Show description only'))
Ejemplo n.º 49
0
 def testSetSingleConfigItem(self):
     value = IntegerValue(BASE_GROUP, 'SingleItem')
     config_register(value)
     self.assert_(config_exists(BASE_GROUP, 'SingleItem'))
Ejemplo n.º 50
0
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))

ENFORCE_STATE = config_register(
    BooleanValue(
        SHOP_GROUP,
        'ENFORCE_STATE',
        description=_('State required?'),
        help_text=
        _("Require a state during registration/checkout for countries that have states?"
          ),
        default=True))

SHOW_SITE = config_register(
Ejemplo n.º 51
0
from django.utils.translation import ugettext_lazy as _

from livesettings.values import ConfigurationGroup, StringValue
from livesettings.functions import config_register
import logging
log = logging.getLogger('tiered.config')
from shipping.config import SHIPPING_ACTIVE

SHIPPING_ACTIVE.add_choice(('shipping.modules.tiered', _('Tiered Shipping')))

log.debug('loaded')

SHIPPING_TIERED_GROUP = ConfigurationGroup('SHIPPING_TIERED',
                                           _('Shipping Tiered Settings'))

config_register(
    StringValue(
        SHIPPING_TIERED_GROUP,
        'MIN_PRICE_FOR',
        description=_("Min Price relates to"),
        help_text=_("By default Min Price only for total of shippable items"),
        default='SHIPPABLE',
        ordering=15,
        choices=(
            ('SHIPPABLE', _('Only shippable items')),
            ('NOT_DISCOUNTABLE', _('Not discountable total')),
        )))
Ejemplo n.º 52
0
from livesettings.values import IntegerValue
from livesettings.functions import config_register
from django.utils.translation import ugettext_lazy as _
from product.config import PRODUCT_GROUP
config_register(
    IntegerValue(
        PRODUCT_GROUP,
        'RECENT_MAX',
        description=_("Maximum recent items"),
        help_text=_("""The maximum number of items show in the recent box."""),
        default=4,
    ), )
Ejemplo n.º 53
0
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))

PAYMENT_LIVE = config_register(
Ejemplo n.º 54
0
from django.utils.translation import ugettext_lazy as _
from livesettings.functions import config_register, config_register_list, config_get
from livesettings.values import *

# Default values should be specified explicitely, otherwise it would be
# an error if nothing is saved in the database and no default is found.

# First, setup a group to hold all our possible configs
MYAPP_GROUP = ConfigurationGroup('MyApp', _('My App Settings'), ordering=0)

# Now, add our number of images to display value
# If a user doesn't enter a value, default to 5
config_register(
    PositiveIntegerValue(
        MYAPP_GROUP,
        'NUM_IMAGES',
        description=_('Number of images to display'),
        help_text=_("How many images to display on front page."),
        # if no help_text is given, Default falue is displayed
        default=5))

# Another example of allowing the user to select from several values
config_register(
    MultipleStringValue(MYAPP_GROUP,
                        'MEASUREMENT_SYSTEM',
                        description=_("Measurement System"),
                        help_text=_("Default measurement system to use."),
                        choices=[('metric', _('Metric')),
                                 ('imperial', _('Imperial'))],
                        default="imperial"))

# Because we did not used "ordering" for values, all inputs are sorted alphabetically by name
Ejemplo n.º 55
0
from django.utils.translation import ugettext_lazy as _
from livesettings.values import BooleanValue,DecimalValue
from livesettings.functions import config_register,config_get_group
from tax.config import TAX_MODULE

TAX_MODULE.add_choice(('tax.modules.percent', _('Percent Tax')))
TAX_GROUP = config_get_group('TAX')

config_register(
    DecimalValue(TAX_GROUP,
        'PERCENT',
        description=_("Percent tax"),
        requires=TAX_MODULE,
        requiresvalue='tax.modules.percent',
        default="0")
)

config_register(
    BooleanValue(TAX_GROUP,
        'TAX_SHIPPING_PERCENT',
        description=_("Tax Shipping?"),
        requires=TAX_MODULE,
        requiresvalue='tax.modules.percent',
        default=False)
)
Ejemplo n.º 56
0
 def testSetGroup(self):
     g1 = ConfigurationGroup('test1', 'test1')
     value = IntegerValue(g1, 'SingleGroupedItem')
     config_register(value)
     self.assertFalse(config_exists(BASE_GROUP, 'SingleGroupedItem'))
     self.assertTrue(config_exists(g1, 'SingleGroupedItem'))
Ejemplo n.º 57
0
 def setUp(self):
     keyedcache.cache_delete()
     wide = config_register(LongStringValue(BASE_GROUP, 'LONG', ordering=1, default="woot"))
     self.wide = wide
     self.wide.update('*' * 1000)
Ejemplo n.º 58
0
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)
)

PAYMENT_LIVE = config_register(
    BooleanValue(PAYMENT_GROUP,
        'LIVE',
Ejemplo n.º 59
0
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from livesettings.values import StringValue, BooleanValue
from livesettings.functions import config_register
from product.config import PRODUCT_GROUP

ENABLE_AKISMET = config_register(
    BooleanValue(PRODUCT_GROUP,
                 'AKISMET_ENABLE',
                 description=_("Enable Akismet ratings"),
                 default=False))

AKISMET = config_register(
    StringValue(PRODUCT_GROUP,
                'AKISMET_KEY',
                description=_("Akismet API Key"),
                requires=ENABLE_AKISMET,
                default=""))
Ejemplo n.º 60
0
from django.utils.translation import ugettext_lazy as _
from livesettings.functions import config_register, config_register_list, config_get
from livesettings.values import *

# Default values should be specified explicitely, otherwise it would be
# an error if nothing is saved in the database and no default is found.

# First, setup a group to hold all our possible configs
MYAPP_GROUP = ConfigurationGroup('MyApp', _('My App Settings'), ordering=0)

# Now, add our number of images to display value
# If a user doesn't enter a value, default to 5
config_register(PositiveIntegerValue(
    MYAPP_GROUP,
    'NUM_IMAGES',
    description=_('Number of images to display'),
    help_text=_("How many images to display on front page."),
    # if no help_text is given, Default falue is displayed
    default=5
))

# Another example of allowing the user to select from several values
config_register(MultipleStringValue(
    MYAPP_GROUP,
    'MEASUREMENT_SYSTEM',
    description=_("Measurement System"),
    help_text=_("Default measurement system to use."),
    choices=[('metric', _('Metric')),
             ('imperial', _('Imperial'))],
    default="imperial"
))