Mercurial > public > sg101
diff membermap/forms.py @ 1024:6164cc091649
Perform image_check on membermap messages.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 10 Dec 2015 21:11:10 -0600 |
parents | 21c592cac71c |
children | 26f2b83e7468 |
line wrap: on
line diff
--- a/membermap/forms.py Thu Dec 10 20:57:50 2015 -0600 +++ b/membermap/forms.py Thu Dec 10 21:11:10 2015 -0600 @@ -3,6 +3,9 @@ """ from django import forms +from core.html import ImageCheckError +from core.html import image_check +from core.markup import site_markup from membermap.models import MapEntry @@ -12,6 +15,19 @@ message = forms.CharField(required=False, widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) + def clean_message(self): + message = self.cleaned_data['message'] + self.html = None + + if message: + self.html = site_markup(message) + try: + image_check(self.html) + except ImageCheckError as ex: + raise forms.ValidationError(str(ex)) + + return message + class Meta: model = MapEntry fields = ('location', 'message')