예제 #1
0
    def setUp(self):
        self.test_group = {
            'key': 'test_group',
            'name': "Test settings",
            'description': "Those are test settings.",
            '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
                        },
                },
            )
        }

        migrationutils.migrate_settings_group(apps, self.test_group)
        self.groups_count = SettingsGroup.objects.count()
예제 #2
0
    def test_setting_lazy(self):
        """lazy settings work"""
        test_group = {
            'key':
            'test_group',
            'name':
            "Test settings",
            'description':
            "Those are test settings.",
            'settings': [
                {
                    'setting': 'fish_name',
                    'name': "Fish's name",
                    'value': "Greedy Eric",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255,
                    },
                    'is_lazy': False,
                },
                {
                    'setting': 'lazy_fish_name',
                    'name': "Fish's name",
                    'value': "Lazy Eric",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255,
                    },
                    'is_lazy': True,
                },
                {
                    'setting': 'lazy_empty_setting',
                    'name': "Fish's name",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255,
                    },
                    'is_lazy': True,
                },
            ],
        }

        migrate_settings_group(apps, test_group)

        self.assertTrue(gateway.lazy_fish_name)
        self.assertTrue(db_settings.lazy_fish_name)

        self.assertTrue(gateway.lazy_fish_name)
        self.assertEqual(gateway.get_lazy_setting('lazy_fish_name'),
                         'Lazy Eric')
        self.assertTrue(db_settings.lazy_fish_name)
        self.assertEqual(db_settings.get_lazy_setting('lazy_fish_name'),
                         'Lazy Eric')

        self.assertTrue(gateway.lazy_empty_setting is None)
        self.assertTrue(db_settings.lazy_empty_setting is None)
        with self.assertRaises(ValueError):
            db_settings.get_lazy_setting('fish_name')
예제 #3
0
def create_threads_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps,
        {
            'key': 'threads',
            'name': _("Threads"),
            'description': _("Those settings control threads and posts."),
            'settings': (
                {
                    'setting': 'thread_title_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed thread title length."),
                    'legend': _("Thread titles"),
                    'python_type': 'int',
                    'value': 5,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'thread_title_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed thread length."),
                    'python_type': 'int',
                    'value': 90,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'post_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed user post length."),
                    'legend': _("Posts"),
                    'python_type': 'int',
                    'value': 5,
                    'field_extra': {
                        'min_value': 1,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'post_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed user post length. Enter zero to disable"),
                    'python_type': 'int',
                    'value': 60000,
                    'field_extra': {
                        'min_value': 0,
                    },
                    'is_public': True,
                },
            )
        })
예제 #4
0
    def test_setting_lazy(self):
        """lazy settings work"""
        test_group = {
            'key': 'test_group',
            'name': "Test settings",
            'description': "Those are test settings.",
            'settings': (
                {
                    'setting': 'fish_name',
                    'name': "Fish's name",
                    'value': "Greedy Eric",
                    'field_extra': {
                            'min_length': 2,
                            'max_length': 255
                        },
                    'is_lazy': False
                },
                {
                    'setting': 'lazy_fish_name',
                    'name': "Fish's name",
                    'value': "Lazy Eric",
                    'field_extra': {
                            'min_length': 2,
                            'max_length': 255
                        },
                    'is_lazy': True
                },
                {
                    'setting': 'lazy_empty_setting',
                    'name': "Fish's name",
                    'field_extra': {
                            'min_length': 2,
                            'max_length': 255
                        },
                    'is_lazy': True
                },
            )
        }

        migrate_settings_group(apps, test_group)

        self.assertTrue(gateway.lazy_fish_name)
        self.assertTrue(db_settings.lazy_fish_name)

        self.assertTrue(gateway.lazy_fish_name)
        self.assertEqual(
            gateway.get_lazy_setting('lazy_fish_name'), 'Lazy Eric')
        self.assertTrue(db_settings.lazy_fish_name)
        self.assertEqual(
            db_settings.get_lazy_setting('lazy_fish_name'), 'Lazy Eric')

        self.assertTrue(gateway.lazy_empty_setting is None)
        self.assertTrue(db_settings.lazy_empty_setting is None)
        with self.assertRaises(ValueError):
            db_settings.get_lazy_setting('fish_name')
예제 #5
0
def create_threads_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps,
        {
            'key': 'threads',
            'name': _("Threads"),
            'description': _("Those settings control threads and posts."),
            'settings': (
                {
                    'setting': 'thread_title_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed thread title length."),
                    'legend': _("Thread titles"),
                    'python_type': 'int',
                    'value': 5,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                },
                {
                    'setting': 'thread_title_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed thread length."),
                    'python_type': 'int',
                    'value': 90,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                },
                {
                    'setting': 'post_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed user post length."),
                    'legend': _("Posts"),
                    'python_type': 'int',
                    'value': 5,
                    'field_extra': {
                        'min_value': 1,
                    },
                },
                {
                    'setting': 'post_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed user post length. Enter zero to disable"),
                    'python_type': 'int',
                    'value': 60000,
                    'field_extra': {
                        'min_value': 0,
                    },
                },
            )
        })
예제 #6
0
def create_basic_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps,
        {
            'key': 'basic',
            'name': _("Basic forum settings"),
            'description': _("Those settings control most basic properties "
                             "of your forum like its name or description."),
            'settings': (
                {
                    'setting': 'forum_name',
                    'name': _("Forum name"),
                    'legend': _("General"),
                    'value': "Misago",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255
                    },
                    'is_public': True,
                },
                {
                    'setting': 'forum_index_title',
                    'name': _("Index title"),
                    'description': _("You may set custon title on "
                                     "forum index by typing it here."),
                    'legend': _("Forum index"),
                    'field_extra': {
                        'max_length': 255
                    },
                    'is_public': True,
                },
                {
                    'setting': 'forum_index_meta_description',
                    'name': _("Meta Description"),
                    'description': _("Short description of your forum "
                                     "for internet crawlers."),
                    'field_extra': {
                        'max_length': 255
                    },
                },
                {
                    'setting': 'email_footer',
                    'name': _("E-mails footer"),
                    'description': _("Optional short message included "
                                     "at the end of e-mails sent by "
                                     "forum"),
                    'legend': _("Forum e-mails"),
                    'field_extra': {
                        'max_length': 255
                    },
                },
            )
        })
예제 #7
0
    def test_change_group_key(self):
        """migrate_settings_group changed group key"""

        new_group = {
            'key': 'new_test_group',
            'name': "New test settings",
            'description': "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,
                    },
                },
                {
                    'setting': 'fish_new_license_no',
                    'name': "Fish's changed license number",
                    'default_value': '123-456',
                    'field_extra': {
                        'max_length': 255,
                    },
                },
            ],
        }

        migrationutils.migrate_settings_group(
            apps, new_group, old_group_key=self.test_group['key']
        )

        db_group = migrationutils.get_group(
            apps.get_model('misago_conf', 'SettingsGroup'), new_group['key']
        )

        self.assertEqual(SettingsGroup.objects.count(), self.groups_count)
        self.assertEqual(db_group.key, new_group['key'])
        self.assertEqual(db_group.name, new_group['name'])
        self.assertEqual(db_group.description, new_group['description'])

        for setting in new_group['settings']:
            db_setting = db_group.setting_set.get(setting=setting['setting'])
            self.assertEqual(db_setting.name, setting['name'])
예제 #8
0
def delete_deprecated_settings(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key': 'legal',
            'name': _("Legal information"),
            'description': _("Those settings allow you to set additional legal information for your forum."),
            'settings': [
                {
                    'setting': 'forum_footnote',
                    'name': _("Footnote"),
                    'description': _("Short message displayed in forum footer."),
                    'legend': _("Forum footer"),
                    'field_extra': {
                        'max_length': 300,
                    },
                    'is_public': True,
                },
            ],
        }
    )
예제 #9
0
    def test_setting_public(self):
        """get_public_settings returns public settings"""
        test_group = {
            'key':
            'test_group',
            'name':
            "Test settings",
            'description':
            "Those are test settings.",
            'settings': [
                {
                    'setting': 'fish_name',
                    'name': "Fish's name",
                    'value': "Public Eric",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'private_fish_name',
                    'name': "Fish's name",
                    'value': "Private Eric",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255,
                    },
                    'is_public': False,
                },
            ],
        }

        migrate_settings_group(apps, test_group)

        self.assertEqual(gateway.fish_name, 'Public Eric')
        self.assertEqual(gateway.private_fish_name, 'Private Eric')

        public_settings = list(gateway.get_public_settings().keys())
        self.assertIn('fish_name', public_settings)
        self.assertNotIn('private_fish_name', public_settings)
    def test_setting_public(self):
        """get_public_settings returns public settings"""
        test_group = {
            'key': 'test_group',
            'name': "Test settings",
            'description': "Those are test settings.",
            'settings': [
                {
                    'setting': 'fish_name',
                    'name': "Fish's name",
                    'value': "Public Eric",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'private_fish_name',
                    'name': "Fish's name",
                    'value': "Private Eric",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255,
                    },
                    'is_public': False,
                },
            ],
        }

        migrate_settings_group(apps, test_group)

        self.assertEqual(gateway.fish_name, 'Public Eric')
        self.assertEqual(gateway.private_fish_name, 'Private Eric')

        public_settings = gateway.get_public_settings().keys()
        self.assertIn('fish_name', public_settings)
        self.assertNotIn('private_fish_name', public_settings)
예제 #11
0
def create_legal_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key':
            'legal',
            'name':
            _("Legal information"),
            'description':
            _("Those settings allow you to set forum terms of "
              "service and privacy policy"),
            'settings': (
                {
                    'setting':
                    'terms_of_service_title',
                    'name':
                    _("Terms title"),
                    'legend':
                    _("Terms of Service"),
                    'description':
                    _("Leave this field empty to "
                      "use default title."),
                    'value':
                    "",
                    'field_extra': {
                        'max_length': 255,
                        'required': False,
                    },
                    'is_public':
                    True,
                },
                {
                    'setting':
                    'terms_of_service_link',
                    'name':
                    _("Terms link"),
                    'description':
                    _("If terms of service are located "
                      "on other page, enter there its link."),
                    'value':
                    "",
                    'field_extra': {
                        'max_length': 255,
                        'required': False,
                    },
                    'is_public':
                    True,
                },
                {
                    'setting':
                    'terms_of_service',
                    'name':
                    _("Terms contents"),
                    'description':
                    _("Your forums can have custom terms of "
                      "service page. To create it, write or "
                      "paste here its contents. Full Misago "
                      "markup is available for formatting."),
                    'value':
                    "",
                    'form_field':
                    'textarea',
                    'field_extra': {
                        'max_length': 128000,
                        'required': False,
                        'rows': 8,
                    },
                    'is_public':
                    True,
                    'is_lazy':
                    True,
                },
                {
                    'setting':
                    'privacy_policy_title',
                    'name':
                    _("Policy title"),
                    'legend':
                    _("Privacy policy"),
                    'description':
                    _("Leave this field empty to "
                      "use default title."),
                    'value':
                    "",
                    'field_extra': {
                        'max_length': 255,
                        'required': False,
                    },
                    'is_public':
                    True,
                },
                {
                    'setting':
                    'privacy_policy_link',
                    'name':
                    _("Policy link"),
                    'description':
                    _("If privacy policy is located on "
                      "other page, enter there its link."),
                    'value':
                    "",
                    'field_extra': {
                        'max_length': 255,
                        'required': False,
                    },
                    'is_public':
                    True,
                },
                {
                    'setting':
                    'privacy_policy',
                    'name':
                    _("Policy contents"),
                    'description':
                    _("Your forums can have custom privacy "
                      "policy page. To create it, write or "
                      "paste here its contents. Full Misago "
                      "markup is available for formatting."),
                    'value':
                    "",
                    'form_field':
                    'textarea',
                    'field_extra': {
                        'max_length': 128000,
                        'required': False,
                        'rows': 8,
                    },
                    'is_public':
                    True,
                    'is_lazy':
                    True,
                },
                {
                    'setting': 'forum_footnote',
                    'name': _("Footnote"),
                    'description': _("Short message displayed "
                                     "in forum footer."),
                    'legend': _("Forum footer"),
                    'field_extra': {
                        'max_length': 300
                    },
                    'is_public': True,
                },
            )
        })
예제 #12
0
def create_users_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps,
        {
            'key': 'users',
            'name': _("Users"),
            'description': _("Those settings control user accounts default behaviour and features availability."),
            'settings': (
                {
                    'setting': 'account_activation',
                    'name': _("New accounts activation"),
                    'legend': _("New accounts"),
                    'value': 'none',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('none', _("No activation required")),
                            ('user', _("Activation Token sent to User")),
                            ('admin', _("Activation by Administrator")),
                            ('closed', _("Don't allow new registrations"))
                        )
                    },
                    'is_public': True,
                },
                {
                    'setting': 'username_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed username length."),
                    'legend': _("User names"),
                    'python_type': 'int',
                    'value': 3,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 20,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'username_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed username length."),
                    'python_type': 'int',
                    'value': 14,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 20,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'password_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed user password length."),
                    'legend': _("Passwords"),
                    'python_type': 'int',
                    'value': 5,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'allow_custom_avatars',
                    'name': _("Allow custom avatars"),
                    'legend': _("Avatars"),
                    'description': _("Turning this option off will forbid "
                                     "forum users from using avatars from "
                                     "outside forums. Good for forums "
                                     "adressed at young users."),
                    'python_type': 'bool',
                    'value': True,
                    'form_field': 'yesno',
                },
                {
                    'setting': 'default_avatar',
                    'name': _("Default avatar"),
                    'value': 'gravatar',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('dynamic', _("Individual")),
                            ('gravatar', _("Gravatar")),
                            ('gallery', _("Random avatar from gallery")),
                        ),
                    },
                },
                {
                    'setting': 'default_gravatar_fallback',
                    'name': _("Fallback for default gravatar"),
                    'description': _("Select which avatar to use when user "
                                     "has no gravatar associated with his "
                                     "e-mail address."),
                    'value': 'dynamic',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('dynamic', _("Individual")),
                            ('gallery', _("Random avatar from gallery")),
                        ),
                    },
                },
                {
                    'setting': 'avatar_upload_limit',
                    'name': _("Maximum size of uploaded avatar"),
                    'description': _("Enter maximum allowed file size "
                                     "(in KB) for avatar uploads"),
                    'python_type': 'int',
                    'value': 1536,
                    'field_extra': {
                        'min_value': 0,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'signature_length_max',
                    'name': _("Maximum length"),
                    'legend': _("Signatures"),
                    'description': _("Maximum allowed signature length."),
                    'python_type': 'int',
                    'value': 256,
                    'field_extra': {
                        'min_value': 10,
                        'max_value': 5000,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'subscribe_start',
                    'name': _("Started threads"),
                    'legend': _("Default subscriptions settings"),
                    'value': 'watch_email',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('no', _("Don't watch")),
                            ('watch', _("Put on watched threads list")),
                            ('watch_email', _("Put on watched threads "
                                              "list and e-mail user when "
                                              "somebody replies")),
                        ),
                    },
                },
                {
                    'setting': 'subscribe_reply',
                    'name': _("Replied threads"),
                    'value': 'watch_email',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('no', _("Don't watch")),
                            ('watch', _("Put on watched threads list")),
                            ('watch_email', _("Put on watched threads "
                                              "list and e-mail user when "
                                              "somebody replies")),
                        ),
                    },
                },
            )
        })

    migrate_settings_group(
        apps,
        {
            'key': 'captcha',
            'name': _("CAPTCHA"),
            'description': _("Those settings allow you to combat automatic "
                             "registrations on your forum."),
            'settings': (
                {
                    'setting': 'captcha_type',
                    'name': _("Select CAPTCHA type"),
                    'legend': _("CAPTCHA type"),
                    'value': 'no',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('no', _("No CAPTCHA")),
                            ('re', _("reCaptcha")),
                            ('qa', _("Question and answer")),
                        ),
                    },
                    'is_public': True,
                },
                {
                    'setting': 'recaptcha_site_key',
                    'name': _("Site key"),
                    'legend': _("reCAPTCHA"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 100,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'recaptcha_secret_key',
                    'name': _("Secret key"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 100,
                    },
                },
                {
                    'setting': 'qa_question',
                    'name': _("Test question"),
                    'legend': _("Question and answer"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 250,
                    },
                },
                {
                    'setting': 'qa_help_text',
                    'name': _("Question help text"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 250,
                    },
                },
                {
                    'setting': 'qa_answers',
                    'name': _("Valid answers"),
                    'description': _("Enter each answer in new line. "
                                     "Answers are case-insensitive."),
                    'value': '',
                    'form_field': 'textarea',
                    'field_extra': {
                        'rows': 4,
                        'required': False,
                        'max_length': 250,
                    },
                },
            )
        })
예제 #13
0
def create_basic_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key':
            'basic',
            'name':
            _("Basic forum settings"),
            'description':
            _("Those settings control most basic properties "
              "of your forum like its name or description."),
            'settings': (
                {
                    'setting': 'forum_name',
                    'name': _("Forum name"),
                    'legend': _("General"),
                    'value': "Misago",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255
                    },
                },
                {
                    'setting':
                    'forum_index_title',
                    'name':
                    _("Index title"),
                    'description':
                    _("You may set custon title on "
                      "forum index by typing it here."),
                    'legend':
                    _("Forum index"),
                    'field_extra': {
                        'max_length': 255
                    },
                },
                {
                    'setting':
                    'forum_index_meta_description',
                    'name':
                    _("Meta Description"),
                    'description':
                    _("Short description of your forum "
                      "for internet crawlers."),
                    'field_extra': {
                        'max_length': 255
                    },
                },
                {
                    'setting':
                    'email_footer',
                    'name':
                    _("E-mails footer"),
                    'description':
                    _("Optional short message included "
                      "at the end of e-mails sent by "
                      "forum"),
                    'legend':
                    _("Forum e-mails"),
                    'field_extra': {
                        'max_length': 255
                    },
                },
            )
        })

    migrate_settings_group(
        apps, {
            'key':
            'captcha',
            'name':
            _("CAPTCHA"),
            'description':
            _("Those settings allow you to combat automatic "
              "registrations and spam messages on your forum."),
            'settings': (
                {
                    'setting': 'captcha_on_registration',
                    'name': _("CAPTCHA on registration"),
                    'legend': _("CAPTCHA types"),
                    'value': 'no',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('no', _("No protection")),
                            ('recaptcha', _("reCaptcha")),
                            ('qa', _("Question and answer")),
                        ),
                    },
                },
                {
                    'setting': 'recaptcha_public_api_key',
                    'name': _("Public API key"),
                    'legend': _("reCAPTCHA"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 100,
                    },
                },
                {
                    'setting': 'recaptcha_private_api_key',
                    'name': _("Private API key"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 100,
                    },
                },
                {
                    'setting': 'qa_question',
                    'name': _("Test question"),
                    'legend': _("Question and answer"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 250,
                    },
                },
                {
                    'setting': 'qa_help_text',
                    'name': _("Question help text"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 250,
                    },
                },
                {
                    'setting':
                    'qa_answers',
                    'name':
                    _("Valid answers"),
                    'description':
                    _("Enter each answer in new line. "
                      "Answers are case-insensitive."),
                    'value':
                    '',
                    'form_field':
                    'textarea',
                    'field_extra': {
                        'rows': 4,
                        'required': False,
                        'max_length': 250,
                    },
                },
            )
        })
예제 #14
0
def create_basic_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key':
            'basic',
            'name':
            _("Basic forum settings"),
            'description':
            _("Those settings control most basic properties "
              "of your forum like its name or description."),
            'settings': [
                {
                    'setting': 'forum_name',
                    'name': _("Forum name"),
                    'legend': _("General"),
                    'value': "Misago",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255
                    },
                    'is_public': True,
                },
                {
                    'setting':
                    'forum_index_title',
                    'name':
                    _("Index title"),
                    'description':
                    _("You may set custon title on forum index by typing it here."
                      ),
                    'legend':
                    _("Forum index"),
                    'field_extra': {
                        'max_length': 255
                    },
                    'is_public':
                    True,
                },
                {
                    'setting':
                    'forum_index_meta_description',
                    'name':
                    _("Meta Description"),
                    'description':
                    _("Short description of your forum for internet crawlers."
                      ),
                    'field_extra': {
                        'max_length': 255
                    },
                },
                {
                    'setting': 'forum_branding_display',
                    'name': _("Display branding"),
                    'description': _("Switch branding in forum's navbar."),
                    'legend': _("Branding"),
                    'value': True,
                    'python_type': 'bool',
                    'form_field': 'yesno',
                    'is_public': True,
                },
                {
                    'setting':
                    'forum_branding_text',
                    'name':
                    _("Branding text"),
                    'description':
                    _("Optional text displayed besides brand image in navbar."
                      ),
                    'value':
                    "Misago",
                    'field_extra': {
                        'max_length': 255
                    },
                    'is_public':
                    True,
                },
                {
                    'setting':
                    'email_footer',
                    'name':
                    _("E-mails footer"),
                    'description':
                    _("Optional short message included at the end of e-mails sent by forum."
                      ),
                    'legend':
                    _("Forum e-mails"),
                    'field_extra': {
                        'max_length': 255
                    },
                },
            ],
        })
def create_legal_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key': 'legal',
            'name': _("Legal information"),
            'description': _("Those settings allow you to set forum terms of service and privacy policy."),
            'settings': [
                {
                    'setting': 'terms_of_service_title',
                    'name': _("Terms title"),
                    'legend': _("Terms of Service"),
                    'description': _("Leave this field empty to use default title."),
                    'value': "",
                    'field_extra': {
                        'max_length': 255,
                        'required': False,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'terms_of_service_link',
                    'name': _("Terms link"),
                    'description': _("If terms of service are located on other page, enter there its link."),
                    'value': "",
                    'field_extra': {
                        'max_length': 255,
                        'required': False,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'terms_of_service',
                    'name': _("Terms contents"),
                    'description': _(
                        "Your forums can have custom terms of "
                        "service page. To create it, write or "
                        "paste here its contents. Full Misago "
                        "markup is available for formatting."
                    ),
                    'value': "",
                    'form_field': 'textarea',
                    'field_extra': {
                        'max_length': 128000,
                        'required': False,
                        'rows': 8,
                    },
                    'is_public': True,
                    'is_lazy': True,
                },
                {
                    'setting': 'privacy_policy_title',
                    'name': _("Policy title"),
                    'legend': _("Privacy policy"),
                    'description': _("Leave this field empty to use default title."),
                    'value': "",
                    'field_extra': {
                        'max_length': 255,
                        'required': False,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'privacy_policy_link',
                    'name': _("Policy link"),
                    'description': _("If privacy policy is located on other page, enter there its link."),
                    'value': "",
                    'field_extra': {
                        'max_length': 255,
                        'required': False,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'privacy_policy',
                    'name': _("Policy contents"),
                    'description': _(
                        "Your forums can have custom privacy "
                        "policy page. To create it, write or "
                        "paste here its contents. Full Misago "
                        "markup is available for formatting."
                    ),
                    'value': "",
                    'form_field': 'textarea',
                    'field_extra': {
                        'max_length': 128000,
                        'required': False,
                        'rows': 8,
                    },
                    'is_public': True,
                    'is_lazy': True,
                },
                {
                    'setting': 'forum_footnote',
                    'name': _("Footnote"),
                    'description': _("Short message displayed in forum footer."),
                    'legend': _("Forum footer"),
                    'field_extra': {
                        'max_length': 300,
                    },
                    'is_public': True,
                },
            ],
        }
    )
예제 #16
0
def create_users_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps,
        {
            'key': 'users',
            'name': _("Users"),
            'description': _("Those settings control user accounts default behaviour and features availability."),
            'settings': (
                {
                    'setting': 'account_activation',
                    'name': _("New accounts activation"),
                    'legend': _("New accounts"),
                    'value': 'none',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('none', _("No activation required")),
                            ('user', _("Activation Token sent to User")),
                            ('admin', _("Activation by Administrator")),
                            ('closed', _("Don't allow new registrations"))
                        )
                    },
                    'is_public': True,
                },
                {
                    'setting': 'default_timezone',
                    'name': _("Default timezone"),
                    'description': _("Default timezone for newly "
                                     "registered accouts as well as "
                                     "unsigned users."),
                    'value': 'utc',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': '#TZ#',
                    },
                },
                {
                    'setting': 'username_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed username length."),
                    'legend': _("User names"),
                    'python_type': 'int',
                    'value': 3,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                },
                {
                    'setting': 'username_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed username length."),
                    'python_type': 'int',
                    'value': 14,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                },
                {
                    'setting': 'password_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed user password length."),
                    'legend': _("Passwords"),
                    'python_type': 'int',
                    'value': 5,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                },
                {
                    'setting': 'allow_custom_avatars',
                    'name': _("Allow custom avatars"),
                    'legend': _("Avatars"),
                    'description': _("Turning this option off will forbid "
                                     "forum users from using avatars from "
                                     "outside forums. Good for forums "
                                     "adressed at young users."),
                    'python_type': 'bool',
                    'value': True,
                    'form_field': 'yesno',
                },
                {
                    'setting': 'default_avatar',
                    'name': _("Default avatar"),
                    'value': 'gravatar',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('dynamic', _("Individual")),
                            ('gravatar', _("Gravatar")),
                            ('gallery', _("Random avatar from gallery")),
                        ),
                    },
                },
                {
                    'setting': 'default_gravatar_fallback',
                    'name': _("Fallback for default gravatar"),
                    'description': _("Select which avatar to use when user "
                                     "has no gravatar associated with his "
                                     "e-mail address."),
                    'value': 'dynamic',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('dynamic', _("Individual")),
                            ('gallery', _("Random avatar from gallery")),
                        ),
                    },
                },
                {
                    'setting': 'avatar_upload_limit',
                    'name': _("Maximum size of uploaded avatar"),
                    'description': _("Enter maximum allowed file size "
                                     "(in KB) for avatar uploads"),
                    'python_type': 'int',
                    'value': 750,
                    'field_extra': {
                        'min_value': 0,
                    },
                },
                {
                    'setting': 'signature_length_max',
                    'name': _("Maximum length"),
                    'legend': _("Signatures"),
                    'description': _("Maximum allowed signature length."),
                    'python_type': 'int',
                    'value': 1048,
                    'field_extra': {
                        'min_value': 256,
                        'max_value': 10000,
                    },
                },
                {
                    'setting': 'subscribe_start',
                    'name': _("Started threads"),
                    'legend': _("Default subscriptions settings"),
                    'value': 'watch_email',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('no', _("Don't watch")),
                            ('watch', _("Put on watched threads list")),
                            ('watch_email', _("Put on watched threads "
                                              "list and e-mail user when "
                                              "somebody replies")),
                        ),
                    },
                },
                {
                    'setting': 'subscribe_reply',
                    'name': _("Replied threads"),
                    'value': 'watch_email',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('no', _("Don't watch")),
                            ('watch', _("Put on watched threads list")),
                            ('watch_email', _("Put on watched threads "
                                              "list and e-mail user when "
                                              "somebody replies")),
                        ),
                    },
                },
            )
        })
예제 #17
0
def create_users_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key':
            'users',
            'name':
            _("Users"),
            'description':
            _("Those settings control user accounts default behaviour and features availability."
              ),
            'settings': [
                {
                    'setting': 'account_activation',
                    'name': _("New accounts activation"),
                    'legend': _("New accounts"),
                    'value': 'none',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('none', _("No activation required")),
                            ('user', _("Activation token sent to User")),
                            ('admin', _("Activation by administrator")),
                            ('closed', _("Don't allow new registrations")),
                        ],
                    },
                    'is_public': True,
                },
                {
                    'setting': 'username_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed username length."),
                    'legend': _("User names"),
                    'python_type': 'int',
                    'value': 3,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 20,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'username_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed username length."),
                    'python_type': 'int',
                    'value': 14,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 20,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'password_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed user password length."),
                    'legend': _("Passwords"),
                    'python_type': 'int',
                    'value': 5,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting':
                    'allow_custom_avatars',
                    'name':
                    _("Allow custom avatars"),
                    'legend':
                    _("Avatars"),
                    'description':
                    _("Turning this option off will forbid "
                      "forum users from using avatars from "
                      "outside forums. Good for forums "
                      "adressed at young users."),
                    'python_type':
                    'bool',
                    'value':
                    True,
                    'form_field':
                    'yesno',
                },
                {
                    'setting': 'default_avatar',
                    'name': _("Default avatar"),
                    'value': 'gravatar',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('dynamic', _("Individual")),
                            ('gravatar', _("Gravatar")),
                            ('gallery', _("Random avatar from gallery")),
                        ],
                    },
                },
                {
                    'setting':
                    'default_gravatar_fallback',
                    'name':
                    _("Fallback for default gravatar"),
                    'description':
                    _("Select which avatar to use when user has no "
                      "gravatar associated with his e-mail address."),
                    'value':
                    'dynamic',
                    'form_field':
                    'select',
                    'field_extra': {
                        'choices': [
                            ('dynamic', _("Individual")),
                            ('gallery', _("Random avatar from gallery")),
                        ],
                    },
                },
                {
                    'setting':
                    'avatar_upload_limit',
                    'name':
                    _("Maximum size of uploaded avatar"),
                    'description':
                    _("Enter maximum allowed file size (in KB) for avatar uploads."
                      ),
                    'python_type':
                    'int',
                    'value':
                    1536,
                    'field_extra': {
                        'min_value': 0,
                    },
                    'is_public':
                    True,
                },
                {
                    'setting': 'signature_length_max',
                    'name': _("Maximum length"),
                    'legend': _("Signatures"),
                    'description': _("Maximum allowed signature length."),
                    'python_type': 'int',
                    'value': 256,
                    'field_extra': {
                        'min_value': 10,
                        'max_value': 5000,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'subscribe_start',
                    'name': _("Started threads"),
                    'legend': _("Default subscriptions settings"),
                    'value': 'watch_email',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('no', _("Don't watch")),
                            ('watch', _("Put on watched threads list")),
                            ('watch_email',
                             _("Put on watched threads "
                               "list and e-mail user when "
                               "somebody replies")),
                        ],
                    },
                },
                {
                    'setting': 'subscribe_reply',
                    'name': _("Replied threads"),
                    'value': 'watch_email',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('no', _("Don't watch")),
                            ('watch', _("Put on watched threads list")),
                            ('watch_email',
                             _("Put on watched threads "
                               "list and e-mail user when "
                               "somebody replies")),
                        ],
                    },
                },
            ],
        })

    migrate_settings_group(
        apps, {
            'key':
            'captcha',
            'name':
            _("CAPTCHA"),
            'description':
            _("Those settings allow you to combat automatic registrations on your forum."
              ),
            'settings': [
                {
                    'setting': 'captcha_type',
                    'name': _("Select CAPTCHA type"),
                    'legend': _("CAPTCHA type"),
                    'value': 'no',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('no', _("No CAPTCHA")),
                            ('re', _("reCaptcha")),
                            ('qa', _("Question and answer")),
                        ],
                    },
                    'is_public': True,
                },
                {
                    'setting': 'recaptcha_site_key',
                    'name': _("Site key"),
                    'legend': _("reCAPTCHA"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 100,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'recaptcha_secret_key',
                    'name': _("Secret key"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 100,
                    },
                },
                {
                    'setting': 'qa_question',
                    'name': _("Test question"),
                    'legend': _("Question and answer"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 250,
                    },
                },
                {
                    'setting': 'qa_help_text',
                    'name': _("Question help text"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 250,
                    },
                },
                {
                    'setting':
                    'qa_answers',
                    'name':
                    _("Valid answers"),
                    'description':
                    _("Enter each answer in new line. Answers are case-insensitive."
                      ),
                    'value':
                    '',
                    'form_field':
                    'textarea',
                    'field_extra': {
                        'rows': 4,
                        'required': False,
                        'max_length': 250,
                    },
                },
            ],
        })
def create_basic_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps,
        {
            'key': 'basic',
            'name': _("Basic forum settings"),
            'description': _("Those settings control most basic properties "
                             "of your forum like its name or description."),
            'settings': (
                {
                    'setting': 'forum_name',
                    'name': _("Forum name"),
                    'legend': _("General"),
                    'value': "Misago",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255
                    },
                },
                {
                    'setting': 'forum_index_title',
                    'name': _("Index title"),
                    'description': _("You may set custon title on "
                                     "forum index by typing it here."),
                    'legend': _("Forum index"),
                    'field_extra': {
                        'max_length': 255
                    },
                },
                {
                    'setting': 'forum_index_meta_description',
                    'name': _("Meta Description"),
                    'description': _("Short description of your forum "
                                     "for internet crawlers."),
                    'field_extra': {
                        'max_length': 255
                    },
                },
                {
                    'setting': 'email_footer',
                    'name': _("E-mails footer"),
                    'description': _("Optional short message included "
                                     "at the end of e-mails sent by "
                                     "forum"),
                    'legend': _("Forum e-mails"),
                    'field_extra': {
                        'max_length': 255
                    },
                },
            )
        })

    migrate_settings_group(
        apps,
        {
            'key': 'captcha',
            'name': _("CAPTCHA"),
            'description': _("Those settings allow you to combat automatic "
                             "registrations and spam messages on your forum."),
            'settings': (
                {
                    'setting': 'captcha_on_registration',
                    'name': _("CAPTCHA on registration"),
                    'legend': _("CAPTCHA types"),
                    'value': 'no',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': (
                            ('no', _("No protection")),
                            ('recaptcha', _("reCaptcha")),
                            ('qa', _("Question and answer")),
                        ),
                    },
                },
                {
                    'setting': 'recaptcha_public_api_key',
                    'name': _("Public API key"),
                    'legend': _("reCAPTCHA"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 100,
                    },
                },
                {
                    'setting': 'recaptcha_private_api_key',
                    'name': _("Private API key"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 100,
                    },
                },
                {
                    'setting': 'qa_question',
                    'name': _("Test question"),
                    'legend': _("Question and answer"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 250,
                    },
                },
                {
                    'setting': 'qa_help_text',
                    'name': _("Question help text"),
                    'value': '',
                    'field_extra': {
                        'required': False,
                        'max_length': 250,
                    },
                },
                {
                    'setting': 'qa_answers',
                    'name': _("Valid answers"),
                    'description': _("Enter each answer in new line. "
                                     "Answers are case-insensitive."),
                    'value': '',
                    'form_field': 'textarea',
                    'field_extra': {
                        'rows': 4,
                        'required': False,
                        'max_length': 250,
                    },
                },
            )
        })
def update_users_settings(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key': 'users',
            'name': _("Users"),
            'description': _(
                "Those settings control user accounts default behaviour and features availability."
            ),
            'settings': [
                {
                    'setting': 'account_activation',
                    'name': _("New accounts activation"),
                    'legend': _("New accounts"),
                    'value': 'none',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('none', _("No activation required")),
                            ('user', _("Activation token sent to User")),
                            ('admin', _("Activation by administrator")),
                            ('closed', _("Don't allow new registrations")),
                        ],
                    },
                    'is_public': True,
                },
                {
                    'setting': 'username_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed username length."),
                    'legend': _("User names"),
                    'python_type': 'int',
                    'default_value': 3,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 20,
                    },
                },
                {
                    'setting': 'username_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed username length."),
                    'python_type': 'int',
                    'default_value': 14,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 20,
                    },
                },
                {
                    'setting': 'allow_custom_avatars',
                    'name': _("Allow custom avatars"),
                    'legend': _("Avatars"),
                    'description': _(
                        "Turning this option off will forbid "
                        "forum users from using avatars from "
                        "outside forums. Good for forums "
                        "adressed at young users."
                    ),
                    'python_type': 'bool',
                    'value': True,
                    'form_field': 'yesno',
                },
                {
                    'setting': 'default_avatar',
                    'name': _("Default avatar"),
                    'value': 'gravatar',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('dynamic', _("Individual")),
                            ('gravatar', _("Gravatar")),
                            ('gallery', _("Random avatar from gallery")),
                        ],
                    },
                },
                {
                    'setting': 'default_gravatar_fallback',
                    'name': _("Fallback for default gravatar"),
                    'description': _(
                        "Select which avatar to use when user has no "
                        "gravatar associated with his e-mail address."
                    ),
                    'value': 'dynamic',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('dynamic', _("Individual")),
                            ('gallery', _("Random avatar from gallery")),
                        ],
                    },
                },
                {
                    'setting': 'avatar_upload_limit',
                    'name': _("Maximum size of uploaded avatar"),
                    'description': _("Enter maximum allowed file size (in KB) for avatar uploads."),
                    'python_type': 'int',
                    'default_value': 1536,
                    'field_extra': {
                        'min_value': 0,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'signature_length_max',
                    'name': _("Maximum length"),
                    'legend': _("Signatures"),
                    'description': _("Maximum allowed signature length."),
                    'python_type': 'int',
                    'default_value': 256,
                    'field_extra': {
                        'min_value': 10,
                        'max_value': 5000,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'subscribe_start',
                    'name': _("Started threads"),
                    'legend': _("Default subscriptions settings"),
                    'value': 'watch_email',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('no', _("Don't watch")),
                            ('watch', _("Put on watched threads list")),
                            (
                                'watch_email', _(
                                    "Put on watched threads "
                                    "list and e-mail user when "
                                    "somebody replies"
                                )
                            ),
                        ],
                    },
                },
                {
                    'setting': 'subscribe_reply',
                    'name': _("Replied threads"),
                    'value': 'watch_email',
                    'form_field': 'select',
                    'field_extra': {
                        'choices': [
                            ('no', _("Don't watch")),
                            ('watch', _("Put on watched threads list")),
                            (
                                'watch_email', _(
                                    "Put on watched threads "
                                    "list and e-mail user when "
                                    "somebody replies"
                                )
                            ),
                        ],
                    },
                },
            ],
        }
    )

    delete_settings_cache()
def update_threads_settings(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key': 'threads',
            'name': _("Threads"),
            'description': _("Those settings control threads and posts."),
            'settings': [
                {
                    'setting': 'thread_title_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed thread title length."),
                    'legend': _("Thread titles"),
                    'python_type': 'int',
                    'default_value': 5,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'thread_title_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed thread length."),
                    'python_type': 'int',
                    'default_value': 90,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'post_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed user post length."),
                    'legend': _("Posts"),
                    'python_type': 'int',
                    'default_value': 5,
                    'field_extra': {
                        'min_value': 1,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'post_length_max',
                    'name': _("Maximum length"),
                    'description': _(
                        "Maximum allowed user post length. Enter zero to disable. "
                        "Longer posts are more costful to parse and index."
                    ),
                    'python_type': 'int',
                    'default_value': 60000,
                    'field_extra': {
                        'min_value': 0,
                    },
                    'is_public': True,
                },
            ],
        }
    )

    delete_settings_cache()
예제 #21
0
def update_threads_settings(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key':
            'threads',
            'name':
            _("Threads"),
            'description':
            _("Those settings control threads and posts."),
            'settings': (
                {
                    'setting': 'thread_title_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed thread title length."),
                    'legend': _("Thread titles"),
                    'python_type': 'int',
                    'default_value': 5,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'thread_title_length_max',
                    'name': _("Maximum length"),
                    'description': _("Maximum allowed thread length."),
                    'python_type': 'int',
                    'default_value': 90,
                    'field_extra': {
                        'min_value': 2,
                        'max_value': 255,
                    },
                    'is_public': True,
                },
                {
                    'setting': 'post_length_min',
                    'name': _("Minimum length"),
                    'description': _("Minimum allowed user post length."),
                    'legend': _("Posts"),
                    'python_type': 'int',
                    'default_value': 5,
                    'field_extra': {
                        'min_value': 1,
                    },
                    'is_public': True,
                },
                {
                    'setting':
                    'post_length_max',
                    'name':
                    _("Maximum length"),
                    'description':
                    _("Maximum allowed user post length. Enter zero to disable. "
                      "Longer posts are more costful to parse and index."),
                    'python_type':
                    'int',
                    'default_value':
                    60000,
                    'field_extra': {
                        'min_value': 0,
                    },
                    'is_public':
                    True,
                },
            )
        })

    delete_settings_cache()
예제 #22
0
def create_basic_settings_group(apps, schema_editor):
    migrate_settings_group(
        apps, {
            'key':
            'basic',
            'name':
            _("Basic forum settings"),
            'description':
            _("Those settings control most basic properties "
              "of your forum like its name or description."),
            'settings': (
                {
                    'setting': 'forum_name',
                    'name': _("Forum name"),
                    'legend': _("General"),
                    'value': "Misago",
                    'field_extra': {
                        'min_length': 2,
                        'max_length': 255
                    },
                    'is_public': True,
                },
                {
                    'setting':
                    'forum_index_title',
                    'name':
                    _("Index title"),
                    'description':
                    _("You may set custon title on "
                      "forum index by typing it here."),
                    'legend':
                    _("Forum index"),
                    'field_extra': {
                        'max_length': 255
                    },
                    'is_public':
                    True,
                },
                {
                    'setting':
                    'forum_index_meta_description',
                    'name':
                    _("Meta Description"),
                    'description':
                    _("Short description of your forum "
                      "for internet crawlers."),
                    'field_extra': {
                        'max_length': 255
                    },
                },
                {
                    'setting':
                    'email_footer',
                    'name':
                    _("E-mails footer"),
                    'description':
                    _("Optional short message included "
                      "at the end of e-mails sent by "
                      "forum"),
                    'legend':
                    _("Forum e-mails"),
                    'field_extra': {
                        'max_length': 255
                    },
                },
            )
        })