Rafał Pitoń 8 years ago
parent
commit
b8bea0f807

+ 1 - 1
misago/conf/migrationutils.py

@@ -65,7 +65,7 @@ def migrate_setting(Setting, group, setting_fixture, order, old_value):
     if setting_fixture.get('description'):
     if setting_fixture.get('description'):
         setting_fixture['description'] = setting_fixture.get('description')
         setting_fixture['description'] = setting_fixture.get('description')
 
 
-    if (setting_fixture.get('field_extra') and setting_fixture.get('field_extra').get('choices')):
+    if setting_fixture.get('field_extra') and setting_fixture.get('field_extra').get('choices'):
         untranslated_choices = setting_fixture['field_extra']['choices']
         untranslated_choices = setting_fixture['field_extra']['choices']
         translated_choices = []
         translated_choices = []
         for val, name in untranslated_choices:
         for val, name in untranslated_choices:

+ 34 - 28
misago/conf/tests/test_migrationutils.py

@@ -15,22 +15,25 @@ class DBConfMigrationUtilsTests(TestCase):
                 "Test settings",
                 "Test settings",
             'description':
             'description':
                 "Those are test settings.",
                 "Those are test settings.",
-            'settings': ({
-                'setting': 'fish_name',
-                'name': "Fish's name",
-                'value': "Eric",
-                'field_extra': {
-                    'min_length': 2,
-                    'max_length': 255
+            'settings': [
+                {
+                    'setting': 'fish_name',
+                    'name': "Fish's name",
+                    'value': "Eric",
+                    'field_extra': {
+                        'min_length': 2,
+                        'max_length': 255,
+                    },
                 },
                 },
-            }, {
-                'setting': 'fish_license_no',
-                'name': "Fish's license number",
-                'default_value': '123-456',
-                'field_extra': {
-                    'max_length': 255
+                {
+                    'setting': 'fish_license_no',
+                    'name': "Fish's license number",
+                    'default_value': '123-456',
+                    'field_extra': {
+                        'max_length': 255,
+                    },
                 },
                 },
-            }, )
+            ],
         }
         }
 
 
         migrationutils.migrate_settings_group(apps, self.test_group)
         migrationutils.migrate_settings_group(apps, self.test_group)
@@ -64,22 +67,25 @@ class DBConfMigrationUtilsTests(TestCase):
                 "New test settings",
                 "New test settings",
             'description':
             'description':
                 "Those are updated test settings.",
                 "Those are updated test settings.",
-            'settings': ({
-                'setting': 'fish_new_name',
-                'name': "Fish's new name",
-                'value': "Eric",
-                'field_extra': {
-                    'min_length': 2,
-                    'max_length': 255,
+            'settings': [
+                {
+                    'setting': 'fish_new_name',
+                    'name': "Fish's new name",
+                    'value': "Eric",
+                    'field_extra': {
+                        'min_length': 2,
+                        'max_length': 255,
+                    },
                 },
                 },
-            }, {
-                'setting': 'fish_new_license_no',
-                'name': "Fish's changed license number",
-                'default_value': '123-456',
-                'field_extra': {
-                    'max_length': 255,
+                {
+                    'setting': 'fish_new_license_no',
+                    'name': "Fish's changed license number",
+                    'default_value': '123-456',
+                    'field_extra': {
+                        'max_length': 255,
+                    },
                 },
                 },
-            }, ),
+            ],
         }
         }
 
 
         migrationutils.migrate_settings_group(
         migrationutils.migrate_settings_group(

+ 48 - 41
misago/conf/tests/test_settings.py

@@ -47,25 +47,28 @@ class GatewaySettingsTests(TestCase):
                 "Test settings",
                 "Test settings",
             'description':
             'description':
                 "Those are test settings.",
                 "Those are test settings.",
-            'settings': ({
-                'setting': 'fish_name',
-                'name': "Fish's name",
-                'value': "Public Eric",
-                'field_extra': {
-                    'min_length': 2,
-                    'max_length': 255,
+            'settings': [
+                {
+                    'setting': 'fish_name',
+                    'name': "Fish's name",
+                    'value': "Public Eric",
+                    'field_extra': {
+                        'min_length': 2,
+                        'max_length': 255,
+                    },
+                    'is_public': True,
                 },
                 },
-                'is_public': True,
-            }, {
-                'setting': 'private_fish_name',
-                'name': "Fish's name",
-                'value': "Private Eric",
-                'field_extra': {
-                    'min_length': 2,
-                    'max_length': 255,
+                {
+                    'setting': 'private_fish_name',
+                    'name': "Fish's name",
+                    'value': "Private Eric",
+                    'field_extra': {
+                        'min_length': 2,
+                        'max_length': 255,
+                    },
+                    'is_public': False,
                 },
                 },
-                'is_public': False,
-            }, ),
+            ],
         }
         }
 
 
         migrate_settings_group(apps, test_group)
         migrate_settings_group(apps, test_group)
@@ -86,33 +89,37 @@ class GatewaySettingsTests(TestCase):
                 "Test settings",
                 "Test settings",
             'description':
             'description':
                 "Those are test settings.",
                 "Those are test settings.",
-            'settings': ({
-                'setting': 'fish_name',
-                'name': "Fish's name",
-                'value': "Greedy Eric",
-                'field_extra': {
-                    'min_length': 2,
-                    'max_length': 255
+            'settings': [
+                {
+                    'setting': 'fish_name',
+                    'name': "Fish's name",
+                    'value': "Greedy Eric",
+                    'field_extra': {
+                        'min_length': 2,
+                        'max_length': 255,
+                    },
+                    'is_lazy': False,
                 },
                 },
-                'is_lazy': False
-            }, {
-                'setting': 'lazy_fish_name',
-                'name': "Fish's name",
-                'value': "Lazy Eric",
-                'field_extra': {
-                    'min_length': 2,
-                    'max_length': 255
+                {
+                    'setting': 'lazy_fish_name',
+                    'name': "Fish's name",
+                    'value': "Lazy Eric",
+                    'field_extra': {
+                        'min_length': 2,
+                        'max_length': 255,
+                    },
+                    'is_lazy': True,
                 },
                 },
-                'is_lazy': True
-            }, {
-                'setting': 'lazy_empty_setting',
-                'name': "Fish's name",
-                'field_extra': {
-                    'min_length': 2,
-                    'max_length': 255
+                {
+                    'setting': 'lazy_empty_setting',
+                    'name': "Fish's name",
+                    'field_extra': {
+                        'min_length': 2,
+                        'max_length': 255,
+                    },
+                    'is_lazy': True,
                 },
                 },
-                'is_lazy': True
-            }, )
+            ],
         }
         }
 
 
         migrate_settings_group(apps, test_group)
         migrate_settings_group(apps, test_group)