comparison news/forms.py @ 581:ee87ea74d46b

For Django 1.4, rearranged project structure for new manage.py.
author Brian Neal <bgneal@gmail.com>
date Sat, 05 May 2012 17:10:48 -0500
parents gpp/news/forms.py@bdcce55f137e
children ff645a692791
comparison
equal deleted inserted replaced
580:c525f3e0b5d0 581:ee87ea74d46b
1 """
2 Forms for the news application.
3
4 """
5 from django import forms
6 from django.conf import settings
7
8 from news.models import PendingStory
9 from news.models import Category
10
11
12 class AddNewsForm(forms.ModelForm):
13 """Form for a user to submit a news story to the admins for review."""
14 title = forms.CharField(widget=forms.TextInput(attrs={'size': 52}))
15 short_text = forms.CharField(
16 label="Article text",
17 widget=forms.Textarea(
18 attrs={'rows': 60, 'cols': 80, 'style': 'height:500px'}))
19
20 class Meta:
21 model = PendingStory
22 fields = ['title', 'category', 'short_text']
23
24 class Media:
25 js = settings.GPP_THIRD_PARTY_JS['tiny_mce']
26
27
28 class SendStoryForm(forms.Form):
29 """Form for sending a news story via email to a friend."""
30 friend_name = forms.CharField(label="Friend's Name", max_length=64)
31 friend_email = forms.EmailField(label="Friend's Email")
32
33 def email(self):
34 return self.cleaned_data['friend_email']
35
36 def name(self):
37 return self.cleaned_data['friend_name']
38