annotate news/forms.py @ 887:9a15f7c27526

Actually save model object upon change. This commit was tested on the comments model. Additional logging added. Added check for Markdown image references. Added TODOs after observing behavior on comments.
author Brian Neal <bgneal@gmail.com>
date Tue, 03 Feb 2015 21:09:44 -0600
parents ff645a692791
children 19b86e684cc2
rev   line source
gremmie@1 1 """
gremmie@1 2 Forms for the news application.
bgneal@493 3
gremmie@1 4 """
gremmie@1 5 from django import forms
bgneal@7 6 from django.conf import settings
bgneal@7 7
gremmie@1 8 from news.models import PendingStory
gremmie@1 9
gremmie@1 10
gremmie@1 11 class AddNewsForm(forms.ModelForm):
gremmie@1 12 """Form for a user to submit a news story to the admins for review."""
gremmie@1 13 title = forms.CharField(widget=forms.TextInput(attrs={'size': 52}))
bgneal@493 14 short_text = forms.CharField(
bgneal@493 15 label="Article text",
bgneal@493 16 widget=forms.Textarea(
bgneal@493 17 attrs={'rows': 60, 'cols': 80, 'style': 'height:500px'}))
gremmie@1 18
gremmie@1 19 class Meta:
gremmie@1 20 model = PendingStory
bgneal@493 21 fields = ['title', 'category', 'short_text']
gremmie@1 22
gremmie@1 23 class Media:
bgneal@7 24 js = settings.GPP_THIRD_PARTY_JS['tiny_mce']
gremmie@1 25
gremmie@1 26
gremmie@1 27 class SendStoryForm(forms.Form):
gremmie@1 28 """Form for sending a news story via email to a friend."""
gremmie@1 29 friend_name = forms.CharField(label="Friend's Name", max_length=64)
gremmie@1 30 friend_email = forms.EmailField(label="Friend's Email")
gremmie@1 31
gremmie@1 32 def email(self):
gremmie@1 33 return self.cleaned_data['friend_email']
bgneal@312 34
gremmie@1 35 def name(self):
gremmie@1 36 return self.cleaned_data['friend_name']
gremmie@1 37