Changeset 827:0f14ee78dc4e
- Timestamp:
- 12/30/08 22:59:24 (3 years ago)
- Branch:
- default
- Children:
- 830:556536f6f8b1, 840:4be83bf64ddc
- Location:
- zine
- Files:
-
- 3 edited
-
forms.py (modified) (6 diffs)
-
utils/forms.py (modified) (1 diff)
-
utils/validators.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
zine/forms.py
r810 r827 23 23 from zine.utils.http import redirect_to 24 24 from zine.utils.validators import ValidationError, is_valid_email, \ 25 is_valid_url, is_valid_slug, is_netaddr 25 is_valid_url, is_valid_slug, is_netaddr, is_not_whitespace_only 26 26 from zine.utils.redirects import register_redirect, change_url_prefix 27 27 … … 221 221 """ 222 222 title = forms.TextField(lazy_gettext(u'Title'), max_length=150, 223 required=True)223 validators=[is_not_whitespace_only()], required=True) 224 224 text = forms.TextField(lazy_gettext(u'Text'), max_length=65000, 225 225 widget=forms.Textarea) … … 291 291 existing = query.first() 292 292 if existing is not None: 293 raise ValidationError(_('This slug is already in use '))293 raise ValidationError(_('This slug is already in use.')) 294 294 295 295 def validate_parser(self, value): … … 505 505 506 506 slug = forms.TextField(lazy_gettext(u'Slug'), validators=[is_valid_slug()]) 507 name = forms.TextField(lazy_gettext(u'Name'), max_length=50, required=True) 507 name = forms.TextField(lazy_gettext(u'Name'), max_length=50, required=True, 508 validators=[is_not_whitespace_only()]) 508 509 description = forms.TextField(lazy_gettext(u'Description'), 509 510 max_length=5000, widget=forms.Textarea) … … 609 610 610 611 groupname = forms.TextField(lazy_gettext(u'Groupname'), max_length=30, 611 required=True) 612 validators=[is_not_whitespace_only()], 613 required=True) 612 614 privileges = forms.MultiChoiceField(lazy_gettext(u'Privileges'), 613 615 widget=forms.CheckboxGroup) … … 706 708 707 709 username = forms.TextField(lazy_gettext(u'Username'), max_length=30, 710 validators=[is_not_whitespace_only()], 708 711 required=True) 709 712 real_name = forms.TextField(lazy_gettext(u'Realname'), max_length=180) -
zine/utils/forms.py
r744 r827 974 974 validation if the field is empty and not required. 975 975 976 For example a validator like `is_valid_ip` is never alled if the976 For example a validator like `is_valid_ip` is never called if the 977 977 value is an empty string and the field hasn't raised a validation 978 978 error when checking if the field is required. -
zine/utils/validators.py
r754 r827 156 156 raise ValidationError(_(u'URL prefix must not end with a slash.')) 157 157 return validator 158 159 def is_not_whitespace_only(): 160 """Make sure the value does consist of at least one 161 non-whitespace character""" 162 def validator(form, value): 163 if not value.strip(): 164 raise ValidationError(_('At least one non-whitespace character ' 165 'is required.')) 166 return validator
Note: See TracChangeset
for help on using the changeset viewer.