Browse Source

Settings fixtures are less of pain to maintain.

Ralfp 12 years ago
parent
commit
17ecd11b13

+ 0 - 4
misago/authn/fixtures.py

@@ -15,7 +15,6 @@ settings_fixtures = (
                 'separator':    _("Sessions Settings"),
                 'separator':    _("Sessions Settings"),
                 'name':         _("Check IP on session authorization"),
                 'name':         _("Check IP on session authorization"),
                 'description':  _("Makes sessions more secure, but can cause problems with proxies and VPN's."),
                 'description':  _("Makes sessions more secure, but can cause problems with proxies and VPN's."),
-                'position':     0,
             }),
             }),
             ('remember_me_allow', {
             ('remember_me_allow', {
                 'value':        True,
                 'value':        True,
@@ -24,7 +23,6 @@ settings_fixtures = (
                 'separator':    _('"Remember Me" Feature'),
                 'separator':    _('"Remember Me" Feature'),
                 'name':         _('Enable "Remember Me" feature'),
                 'name':         _('Enable "Remember Me" feature'),
                 'description':  _("Turning this option on allows users to sign in on to your board using cookie-based tokens. This may result in account compromisation when user fails to sign out on shared computer or his cookie is stolen."),
                 'description':  _("Turning this option on allows users to sign in on to your board using cookie-based tokens. This may result in account compromisation when user fails to sign out on shared computer or his cookie is stolen."),
-                'position':     1,
             }),
             }),
             ('remember_me_lifetime', {
             ('remember_me_lifetime', {
                 'value':        90,
                 'value':        90,
@@ -32,7 +30,6 @@ settings_fixtures = (
                 'input':        "text",
                 'input':        "text",
                 'name':         _('"Remember Me" token lifetime'),
                 'name':         _('"Remember Me" token lifetime'),
                 'description':  _('Number of days since either last use or creation of "Remember Me" token to its expiration.'),
                 'description':  _('Number of days since either last use or creation of "Remember Me" token to its expiration.'),
-                'position':     2,
             }),
             }),
             ('remember_me_extensible', {
             ('remember_me_extensible', {
                 'value':        1,
                 'value':        1,
@@ -40,7 +37,6 @@ settings_fixtures = (
                 'input':        "yesno",
                 'input':        "yesno",
                 'name':         _('Allow "Remember Me" tokens refreshing'),
                 'name':         _('Allow "Remember Me" tokens refreshing'),
                 'description':  _('Set this setting to off if you want to force your users to periodically update their "Remember Me" tokens by signing in. If this option is on, Tokens are updated when they are used to open new session.'),
                 'description':  _('Set this setting to off if you want to force your users to periodically update their "Remember Me" tokens by signing in. If this option is on, Tokens are updated when they are used to open new session.'),
-                'position':     3,
             }),
             }),
         ),
         ),
     }),
     }),

+ 0 - 3
misago/bruteforce/fixtures.py

@@ -16,7 +16,6 @@ settings_fixtures = (
                 'separator':    _("Brute-force Countermeasures"),
                 'separator':    _("Brute-force Countermeasures"),
                 'name':         _("IP invalid attempts limit"),
                 'name':         _("IP invalid attempts limit"),
                 'description':  _('Enter maximal number of allowed attempts before IP address "jams". Defautly forum records only failed sign-in attempts.'),
                 'description':  _('Enter maximal number of allowed attempts before IP address "jams". Defautly forum records only failed sign-in attempts.'),
-                'position':     0,
             }),
             }),
             ('registrations_jams', {
             ('registrations_jams', {
                 'value':        1,
                 'value':        1,
@@ -25,7 +24,6 @@ settings_fixtures = (
                 'input':        "yesno",
                 'input':        "yesno",
                 'name':         _("Protect register form"),
                 'name':         _("Protect register form"),
                 'description':  _("Set this setting to yes if you want failed register attempts to count into limit. Majority of failed register attempts are caused by CAPTCHA protection against spam-bots, however same protection may cause problems for users with disabilities or ones that have problems understanding Q&A challenge."),
                 'description':  _("Set this setting to yes if you want failed register attempts to count into limit. Majority of failed register attempts are caused by CAPTCHA protection against spam-bots, however same protection may cause problems for users with disabilities or ones that have problems understanding Q&A challenge."),
-                'position':     1,
             }),
             }),
             ('jams_lifetime', {
             ('jams_lifetime', {
                 'value':        15,
                 'value':        15,
@@ -34,7 +32,6 @@ settings_fixtures = (
                 'input':        "text",
                 'input':        "text",
                 'name':         _("Automaticaly unlock jammed IPs"),
                 'name':         _("Automaticaly unlock jammed IPs"),
                 'description':  _('Enter number of minutes since IP address "jams" to automatically unlock it, or 0 to never unlock jammed IP adresses. Jams don\'t count as bans.'),
                 'description':  _('Enter number of minutes since IP address "jams" to automatically unlock it, or 0 to never unlock jammed IP adresses. Jams don\'t count as bans.'),
-                'position':     2,
             }),
             }),
         ),
         ),
     }),
     }),

+ 0 - 7
misago/captcha/fixtures.py

@@ -16,7 +16,6 @@ settings_fixtures = (
                 'separator':    _("Spambots Registrations"),
                 'separator':    _("Spambots Registrations"),
                 'name':         _("CAPTCHA type"),
                 'name':         _("CAPTCHA type"),
                 'description':  _('CAPTCHA stands for "Completely Automated Public Turing test to tell Computers and Humans Apart". Its type of test developed on purpose of blocking automatic registrations.'),
                 'description':  _('CAPTCHA stands for "Completely Automated Public Turing test to tell Computers and Humans Apart". Its type of test developed on purpose of blocking automatic registrations.'),
-                'position':     0,
             }),
             }),
             ('recaptcha_public', {
             ('recaptcha_public', {
                 'type':         "string",
                 'type':         "string",
@@ -24,14 +23,12 @@ settings_fixtures = (
                 'separator':    _("reCaptcha"),
                 'separator':    _("reCaptcha"),
                 'name':         _("Public Key"),
                 'name':         _("Public Key"),
                 'description':  _("Enter public API key that you have received from reCaptcha."),
                 'description':  _("Enter public API key that you have received from reCaptcha."),
-                'position':     1,
             }),
             }),
             ('recaptcha_private', {
             ('recaptcha_private', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "text",
                 'input':        "text",
                 'name':         _("Private Key"),
                 'name':         _("Private Key"),
                 'description':  _("Enter private API key that you have received from reCaptcha."),
                 'description':  _("Enter private API key that you have received from reCaptcha."),
-                'position':     2,
             }),
             }),
             ('recaptcha_ssl', {
             ('recaptcha_ssl', {
                 'value':        False,
                 'value':        False,
@@ -39,7 +36,6 @@ settings_fixtures = (
                 'input':        "yesno",
                 'input':        "yesno",
                 'name':         _("Use SSL in reCaptcha"),
                 'name':         _("Use SSL in reCaptcha"),
                 'description':  _("Do you want forum to use SSL when making requests to reCaptha servers?"),
                 'description':  _("Do you want forum to use SSL when making requests to reCaptha servers?"),
-                'position':     3,
             }),
             }),
             ('qa_test', {
             ('qa_test', {
                 'type':         "string",
                 'type':         "string",
@@ -47,21 +43,18 @@ settings_fixtures = (
                 'separator':    _("Question and Answer Test"),
                 'separator':    _("Question and Answer Test"),
                 'name':         _("Question"),
                 'name':         _("Question"),
                 'description':  _("Question visible to your users."),
                 'description':  _("Question visible to your users."),
-                'position':     4,
             }),
             }),
             ('qa_test_help', {
             ('qa_test_help', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "text",
                 'input':        "text",
                 'name':         _("Help Message"),
                 'name':         _("Help Message"),
                 'description':  _("Optional help message displayed on form."),
                 'description':  _("Optional help message displayed on form."),
-                'position':     5,
             }),
             }),
             ('qa_test_answers', {
             ('qa_test_answers', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "textarea",
                 'input':        "textarea",
                 'name':         _("Answers"),
                 'name':         _("Answers"),
                 'description':  _("Enter allowed answers to this question, each in new line. Test is case-insensitive."),
                 'description':  _("Enter allowed answers to this question, each in new line. Test is case-insensitive."),
-                'position':     6,
             }),
             }),
         ),
         ),
     }),
     }),

+ 0 - 6
misago/register/fixtures.py

@@ -14,7 +14,6 @@ settings_fixtures = (
                 'extra':        {'choices': [('', _("No validation required")), ('user', _("Activation Token sent to User")), ('admin', _("Activation by Administrator")), ('block', _("Dont allow new registrations"))]},
                 'extra':        {'choices': [('', _("No validation required")), ('user', _("Activation Token sent to User")), ('admin', _("Activation by Administrator")), ('block', _("Dont allow new registrations"))]},
                 'separator':    _("Users Registrations"),
                 'separator':    _("Users Registrations"),
                 'name':         _("New accounts validation"),
                 'name':         _("New accounts validation"),
-                'position':     0,
             }),
             }),
             ('default_timezone', {
             ('default_timezone', {
                 'value':        "utc",
                 'value':        "utc",
@@ -23,7 +22,6 @@ settings_fixtures = (
                 'extra':        {'choices': '#TZ#'},
                 'extra':        {'choices': '#TZ#'},
                 'name':         _("Default Timezone"),
                 'name':         _("Default Timezone"),
                 'description':  _("Used by guests, crawlers and newly registered users."),
                 'description':  _("Used by guests, crawlers and newly registered users."),
-                'position':     1,
             }),
             }),
             ('password_length', {
             ('password_length', {
                 'value':        4,
                 'value':        4,
@@ -32,7 +30,6 @@ settings_fixtures = (
                 'extra':        {'min': 1},
                 'extra':        {'min': 1},
                 'separator':    _("Users Passwords"),
                 'separator':    _("Users Passwords"),
                 'name':         _("Minimum user password length"),
                 'name':         _("Minimum user password length"),
-                'position':     2,
             }),
             }),
             ('password_complexity', {
             ('password_complexity', {
                 'value':        [],
                 'value':        [],
@@ -40,7 +37,6 @@ settings_fixtures = (
                 'input':        "mlist",
                 'input':        "mlist",
                 'extra':        {'choices': [('case', _("Require mixed Case")), ('digits', _("Require digits")), ('special', _("Require special characters"))]},
                 'extra':        {'choices': [('case', _("Require mixed Case")), ('digits', _("Require digits")), ('special', _("Require special characters"))]},
                 'name':         _("Password Complexity"),
                 'name':         _("Password Complexity"),
-                'position':     3,
             }),
             }),
             ('password_lifetime', {
             ('password_lifetime', {
                 'value':        0,
                 'value':        0,
@@ -49,7 +45,6 @@ settings_fixtures = (
                 'extra':        {'min': 0},
                 'extra':        {'min': 0},
                 'name':         _("Password Lifetime"),
                 'name':         _("Password Lifetime"),
                 'description':  _("Enter number of days since password was set to force member to change it with new one, or 0 to dont force your members to change their passwords."),
                 'description':  _("Enter number of days since password was set to force member to change it with new one, or 0 to dont force your members to change their passwords."),
-                'position':     4,
             }),
             }),
             ('password_in_email', {
             ('password_in_email', {
                 'value':        False,
                 'value':        False,
@@ -57,7 +52,6 @@ settings_fixtures = (
                 'input':        "yesno",
                 'input':        "yesno",
                 'name':         _("Include User Password in Welcoming E-mail"),
                 'name':         _("Include User Password in Welcoming E-mail"),
                 'description':  _("If you want to, Misago can include new user password in welcoming e-mail that is sent to new users after successful account creation."),
                 'description':  _("If you want to, Misago can include new user password in welcoming e-mail that is sent to new users after successful account creation."),
-                'position':     5,
             }),
             }),
         ),
         ),
     }),
     }),

+ 3 - 10
misago/settings/fixtures.py

@@ -18,14 +18,12 @@ settings_fixture = (
                 'input':        "text",
                 'input':        "text",
                 'separator':    _("Board Name"),
                 'separator':    _("Board Name"),
                 'name':         _("Board Name"),
                 'name':         _("Board Name"),
-                'position':     0,
             }),
             }),
             ('board_header', {
             ('board_header', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "text",
                 'input':        "text",
                 'name':         _("Board Header"),
                 'name':         _("Board Header"),
                 'description':  _("Some themes allow you to define text in board header. Leave empty to use Board Name instead."),
                 'description':  _("Some themes allow you to define text in board header. Leave empty to use Board Name instead."),
-                'position':     1,
             }),
             }),
             ('board_header_postscript', {
             ('board_header_postscript', {
                 'value':        "Work in progress ",
                 'value':        "Work in progress ",
@@ -33,7 +31,6 @@ settings_fixture = (
                 'input':        "text",
                 'input':        "text",
                 'name':         _("Board Header Postscript"),
                 'name':         _("Board Header Postscript"),
                 'description':  _("Additional text displayed in some themes board header after board name."),
                 'description':  _("Additional text displayed in some themes board header after board name."),
-                'position':     2,
             }),
             }),
             ('board_index_title', {
             ('board_index_title', {
                 'type':         "string",
                 'type':         "string",
@@ -41,14 +38,12 @@ settings_fixture = (
                 'separator':    _("Board Index"),
                 'separator':    _("Board Index"),
                 'name':         _("Board Index Title"),
                 'name':         _("Board Index Title"),
                 'description':  _("If you want to, you can replace page title content on Board Index with custom one."),
                 'description':  _("If you want to, you can replace page title content on Board Index with custom one."),
-                'position':     3,
             }),
             }),
             ('board_index_meta', {
             ('board_index_meta', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "text",
                 'input':        "text",
                 'name':         _("Board Index Meta-Description"),
                 'name':         _("Board Index Meta-Description"),
                 'description':  _("Meta-Description used to describe your board's index page."),
                 'description':  _("Meta-Description used to describe your board's index page."),
-                'position':     4,
             }),
             }),
             ('board_credits', {
             ('board_credits', {
                 'type':         "string",
                 'type':         "string",
@@ -56,7 +51,6 @@ settings_fixture = (
                 'separator':    _("Board Footer"),
                 'separator':    _("Board Footer"),
                 'name':         _("Custom Credit"),
                 'name':         _("Custom Credit"),
                 'description':  _("Custom Credit to display in board footer above software and theme copyright information. You can use HTML."),
                 'description':  _("Custom Credit to display in board footer above software and theme copyright information. You can use HTML."),
-                'position':     5,
             }),
             }),
             ('email_footnote', {
             ('email_footnote', {
                 'type':         "string",
                 'type':         "string",
@@ -64,14 +58,12 @@ settings_fixture = (
                 'separator':    _("Board E-Mails"),
                 'separator':    _("Board E-Mails"),
                 'name':         _("Custom Footnote in HTML E-mails"),
                 'name':         _("Custom Footnote in HTML E-mails"),
                 'description':  _("Custom Footnote to display in HTML e-mail messages sent by board."),
                 'description':  _("Custom Footnote to display in HTML e-mail messages sent by board."),
-                'position':     6,
             }),
             }),
             ('email_footnote_plain', {
             ('email_footnote_plain', {
                 'type':         "string",
                 'type':         "string",
                 'input':        "textarea",
                 'input':        "textarea",
                 'name':         _("Custom Footnote in plain text E-mails"),
                 'name':         _("Custom Footnote in plain text E-mails"),
                 'description':  _("Custom Footnote to display in plain text e-mail messages sent by board."),
                 'description':  _("Custom Footnote to display in plain text e-mail messages sent by board."),
-                'position':     7,
             }),
             }),
         ),
         ),
    }),
    }),
@@ -86,7 +78,7 @@ def load_settings_group_fixture(group, fixture):
                         )
                         )
     model_group.save(force_insert=True)
     model_group.save(force_insert=True)
     fixture = fixture.get('settings', ())
     fixture = fixture.get('settings', ())
-    
+    position = 0
     for setting in fixture:
     for setting in fixture:
         value = setting[1].get('value')
         value = setting[1].get('value')
         value_default = setting[1].get('default')
         value_default = setting[1].get('default')
@@ -107,12 +99,13 @@ def load_settings_group_fixture(group, fixture):
                                 type=setting[1].get('type'),
                                 type=setting[1].get('type'),
                                 input=setting[1].get('input'),
                                 input=setting[1].get('input'),
                                 extra=base64.encodestring(pickle.dumps(setting[1].get('extra', {}), pickle.HIGHEST_PROTOCOL)),
                                 extra=base64.encodestring(pickle.dumps(setting[1].get('extra', {}), pickle.HIGHEST_PROTOCOL)),
-                                position=setting[1].get('position'),
+                                position=position,
                                 separator=get_msgid(setting[1].get('separator')),
                                 separator=get_msgid(setting[1].get('separator')),
                                 name=get_msgid(setting[1].get('name')),
                                 name=get_msgid(setting[1].get('name')),
                                 description=get_msgid(setting[1].get('description')),
                                 description=get_msgid(setting[1].get('description')),
                             )
                             )
         model_setting.save(force_insert=True)
         model_setting.save(force_insert=True)
+        position += 1
 
 
 
 
 def update_settings_group_fixture(group, fixture):
 def update_settings_group_fixture(group, fixture):

+ 8 - 6
misago/threads/fixtures.py

@@ -23,7 +23,14 @@ settings_fixtures = (
                 'separator':    _("Threads"),
                 'separator':    _("Threads"),
                 'name':         _("Min. Thread Name Length"),
                 'name':         _("Min. Thread Name Length"),
                 'description':  _('Minimal allowed thread name length.'),
                 'description':  _('Minimal allowed thread name length.'),
-                'position':     0,
+            }),
+            ('thread_name_max', {
+                'value':        20,
+                'type':         "integer",
+                'input':        "text",
+                'extra':        {'min': 5, 'max': 60},
+                'name':         _("Max. Thread Name Length"),
+                'description':  _('Maximum allowed thread name length.'),
             }),
             }),
             ('threads_per_page', {
             ('threads_per_page', {
                 'value':        40,
                 'value':        40,
@@ -32,7 +39,6 @@ settings_fixtures = (
                 'extra':        {'min': 5},
                 'extra':        {'min': 5},
                 'name':         _("Threads per page"),
                 'name':         _("Threads per page"),
                 'description':  _("Number of threads displayed on page in forum view."),
                 'description':  _("Number of threads displayed on page in forum view."),
-                'position':     1,
             }),
             }),
             ('post_length_min', {
             ('post_length_min', {
                 'value':        5,
                 'value':        5,
@@ -42,7 +48,6 @@ settings_fixtures = (
                 'separator':    _("Posts"),
                 'separator':    _("Posts"),
                 'name':         _("Min. Post Length"),
                 'name':         _("Min. Post Length"),
                 'description':  _("Minimal allowed post length."),
                 'description':  _("Minimal allowed post length."),
-                'position':     2,
             }),
             }),
             ('post_merge_time', {
             ('post_merge_time', {
                 'value':        5,
                 'value':        5,
@@ -51,7 +56,6 @@ settings_fixtures = (
                 'extra':        {'min': 0},
                 'extra':        {'min': 0},
                 'name':         _("Automatic Post Merge timespan"),
                 'name':         _("Automatic Post Merge timespan"),
                 'description':  _("Forum can automatically merge member posts if interval between postings is shorter than specified number of minutes."),
                 'description':  _("Forum can automatically merge member posts if interval between postings is shorter than specified number of minutes."),
-                'position':     3,
             }),
             }),
             ('posts_per_page', {
             ('posts_per_page', {
                 'value':        15,
                 'value':        15,
@@ -60,7 +64,6 @@ settings_fixtures = (
                 'extra':        {'min': 5},
                 'extra':        {'min': 5},
                 'name':         _("Posts per page"),
                 'name':         _("Posts per page"),
                 'description':  _("Number of posts per page in thread view."),
                 'description':  _("Number of posts per page in thread view."),
-                'position':     4,
             }),
             }),
             ('thread_length', {
             ('thread_length', {
                 'value':        300,
                 'value':        300,
@@ -69,7 +72,6 @@ settings_fixtures = (
                 'extra':        {'min': 0},
                 'extra':        {'min': 0},
                 'name':         _("Thread Length Limit"),
                 'name':         _("Thread Length Limit"),
                 'description':  _('Long threads are hard to follow and search. You can force users to create few shorter threads instead of one long by setting thread lenght limits. Users with "Can close threads" permission will still be able to post in threads that have reached posts limit.'),
                 'description':  _('Long threads are hard to follow and search. You can force users to create few shorter threads instead of one long by setting thread lenght limits. Users with "Can close threads" permission will still be able to post in threads that have reached posts limit.'),
-                'position':     5,
             }),
             }),
        ),
        ),
     }),
     }),

+ 0 - 3
misago/usercp/fixtures.py

@@ -16,7 +16,6 @@ settings_fixtures = (
                 'separator':    _("General Settings"),
                 'separator':    _("General Settings"),
                 'name':         _("Allowed Avatars"),
                 'name':         _("Allowed Avatars"),
                 'description':  _("Select Avatar types allowed on your forum."),
                 'description':  _("Select Avatar types allowed on your forum."),
-                'position':     0,
             }),
             }),
             ('default_avatar', {
             ('default_avatar', {
                 'value':        "gravatar",
                 'value':        "gravatar",
@@ -25,7 +24,6 @@ settings_fixtures = (
                 'extra':        {'choices': [('gravatar', _("Gravatar")), ('gallery', _("Random Avatar from Gallery"))]},
                 'extra':        {'choices': [('gravatar', _("Gravatar")), ('gallery', _("Random Avatar from Gallery"))]},
                 'name':         _("Default Avatar"),
                 'name':         _("Default Avatar"),
                 'description':  _("Default Avatar assigned to new members. If you creade directory and name it \"_default\", forum will select random avatar from that directory instead of regular gallery. If no avatar can be picked from gallery, Gravatar will be used."),
                 'description':  _("Default Avatar assigned to new members. If you creade directory and name it \"_default\", forum will select random avatar from that directory instead of regular gallery. If no avatar can be picked from gallery, Gravatar will be used."),
-                'position':     1,
             }),
             }),
             ('upload_limit', {
             ('upload_limit', {
                 'value':        128,
                 'value':        128,
@@ -35,7 +33,6 @@ settings_fixtures = (
                 'separator':    _("Avatar Upload Settings"),
                 'separator':    _("Avatar Upload Settings"),
                 'name':         _("Maxmimum size of uploaded file"),
                 'name':         _("Maxmimum size of uploaded file"),
                 'description':  _("Select maximum allowed file size (in KB) for Avatar uploads."),
                 'description':  _("Select maximum allowed file size (in KB) for Avatar uploads."),
-                'position':     2,
             }),
             }),
        ),
        ),
     }),
     }),