Mercurial > public > sg101
view membermap/forms.py @ 1036:b7b98c729abc
Update news story admin to allow editing comment thread.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 27 Dec 2015 12:00:51 -0600 |
parents | 6164cc091649 |
children | 26f2b83e7468 |
line wrap: on
line source
""" Forms for the member map application. """ 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 class MapEntryForm(forms.ModelForm): location = forms.CharField(required=True, widget=forms.TextInput(attrs={'size': 64, 'maxlength': 255})) 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')