diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-09-22 17:50:27 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-09-22 17:50:27 -0400 |
commit | 44ca8c68afeea6848f750224d00a7d1b1bc09bcb (patch) | |
tree | b639901d9c34aaaab7b9a15840b084d4100c6a27 /askbot/forms.py | |
parent | 4eeda2172a28df85fa4b795f0648add1f5c27f9c (diff) | |
download | askbot-44ca8c68afeea6848f750224d00a7d1b1bc09bcb.tar.gz askbot-44ca8c68afeea6848f750224d00a7d1b1bc09bcb.tar.bz2 askbot-44ca8c68afeea6848f750224d00a7d1b1bc09bcb.zip |
improved tag validation messages and fixed bug where tags were lost in the input box on edit
Diffstat (limited to 'askbot/forms.py')
-rw-r--r-- | askbot/forms.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/askbot/forms.py b/askbot/forms.py index 8548683f..0659e338 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -365,6 +365,10 @@ class TagNamesField(forms.CharField): attrs={'size': 50, 'autocomplete': 'off'} ) self.max_length = 255 + self.error_messages['max_length'] = _( + 'We ran out of space for recording the tags. ' + 'Please shorten or delete some of them.' + ) self.label = _('tags') self.help_text = ungettext_lazy( 'Tags are short keywords, with no spaces within. ' @@ -412,6 +416,11 @@ class TagNamesField(forms.CharField): if cleaned_tag not in cleaned_entered_tags: cleaned_entered_tags.append(clean_tag(tag)) + result = u' '.join(cleaned_entered_tags) + + if len(result) > 125:#magic number!, the same as max_length in db + raise forms.ValidationError(self.error_messages['max_length']) + return u' '.join(cleaned_entered_tags) |