view gpp/news/forms.py @ 385:2a03c69792d8

For #187; tune forums RSS settings. Set TTL to 1 hour; return 30 forum posts instead of 10; cache feed for 15 minutes instead of an hour.
author Brian Neal <bgneal@gmail.com>
date Wed, 16 Mar 2011 02:13:38 +0000
parents 88b2b9cb8c1f
children bdcce55f137e
line wrap: on
line source
"""
Forms for the news application.
"""

from django import forms
from django.conf import settings

from news.models import PendingStory
from news.models import Category


class AddNewsForm(forms.ModelForm):
   """Form for a user to submit a news story to the admins for review."""
   title = forms.CharField(widget=forms.TextInput(attrs={'size': 52}))
   short_text = forms.CharField(widget=forms.Textarea(attrs={'rows': 20, 'cols': 80}))
   long_text = forms.CharField(required=False, widget=forms.Textarea(attrs={'rows': 20, 'cols': 80}))

   class Meta:
      model = PendingStory
      fields = ('title', 'category', 'short_text', 'long_text')

   class Media:
      js = settings.GPP_THIRD_PARTY_JS['tiny_mce']


class SendStoryForm(forms.Form):
   """Form for sending a news story via email to a friend."""
   friend_name = forms.CharField(label="Friend's Name", max_length=64)
   friend_email = forms.EmailField(label="Friend's Email")

   def email(self):
      return self.cleaned_data['friend_email']

   def name(self):
      return self.cleaned_data['friend_name']