def clean(self, value): value = super(HtmlCleaningCharField, self).clean(value) if is_shouting(value): raise forms.ValidationError( 'Please moderate the amount of upper case characters in your post...' ) return clean_html(value)
def clean(self, value): value = super(HtmlCleaningCharField, self).clean(value) if is_shouting(value): raise forms.ValidationError('Please moderate the amount of upper case characters in your post...') try: return clean_html(value) except (HTMLParseError, UnicodeEncodeError): raise forms.ValidationError('The text you submitted is badly formed HTML, please fix it')
def clean(self, value): value = super(HtmlCleaningCharField, self).clean(value) if is_shouting(value): raise forms.ValidationError('Please moderate the amount of upper case characters in your post...') try: return clean_html(value) except HTMLParseError: raise forms.ValidationError('The text you submitted is badly formed HTML, please fix it')
def test_is_shouting(self): (is_shouting('')) self.assertTrue(is_shouting('HELLO THIS IS SHOUTING!!!')) self.assertFalse(is_shouting('This is a phrase WITH SOME emphasis!!')) self.assertFalse(is_shouting('This is a regular phrase.'))