diff options
-rw-r--r-- | askbot/conf/forum_data_rules.py | 18 | ||||
-rw-r--r-- | askbot/forms.py | 12 | ||||
-rw-r--r-- | askbot/skins/common/media/js/post.js | 2 |
3 files changed, 28 insertions, 4 deletions
diff --git a/askbot/conf/forum_data_rules.py b/askbot/conf/forum_data_rules.py index 80af2f5b..a875092e 100644 --- a/askbot/conf/forum_data_rules.py +++ b/askbot/conf/forum_data_rules.py @@ -89,6 +89,24 @@ settings.register( ) settings.register( + livesettings.IntegerValue( + FORUM_DATA_RULES, + 'MIN_TITLE_LENGTH', + default=10, + description=_('Minimum length of title (number of characters)') + ) +) + +settings.register( + livesettings.IntegerValue( + FORUM_DATA_RULES, + 'MIN_EDITOR_LENGTH', + default=10, + description=_('Minimum length of question content (number of characters)') + ) +) + +settings.register( livesettings.StringValue( FORUM_DATA_RULES, 'MANDATORY_TAGS', diff --git a/askbot/forms.py b/askbot/forms.py index 241a52f9..e0c24cfd 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -106,8 +106,10 @@ class TitleField(forms.CharField): self.initial = '' def clean(self, value): - if len(value) < 10: - raise forms.ValidationError(_('title must be > 10 characters')) + if len(value) < askbot_settings.MIN_TITLE_LENGTH: + msg = ungettext_lazy('title must be > %(min_len) characters' + ) % {'min_len': askbot_settings.MIN_TITLE_LENGTH} + raise forms.ValidationError(msg) return value @@ -121,8 +123,10 @@ class EditorField(forms.CharField): self.initial = '' def clean(self, value): - if len(value) < 10: - raise forms.ValidationError(_('question content must be > 10 characters')) + if len(value) < askbot_settings.MIN_EDITOR_LENGTH: + msg = ungettext_lazy('question content must be > %(min_len)d characters' + ) % {'min_len': askbot_settings.MIN_EDITOR_LENGTH} + raise forms.ValidationError(msg) return value class TagNamesField(forms.CharField): diff --git a/askbot/skins/common/media/js/post.js b/askbot/skins/common/media/js/post.js index 59ba4fff..8f6461d0 100644 --- a/askbot/skins/common/media/js/post.js +++ b/askbot/skins/common/media/js/post.js @@ -111,10 +111,12 @@ var CPValidator = function(){ limit_tag_count: true, limit_tag_length: true }, + /* minimum character settings for the title and text can be set in livesettings (under data entry rules) text: { required: true, minlength: 10 } + */ /*title: { required: true, minlength: 10 |