diff gpp/forums/forms.py @ 86:f81226b5e87b

Forums: Some display work for the posts within a topic. Sketched out a post reply form.
author Brian Neal <bgneal@gmail.com>
date Sat, 05 Sep 2009 20:47:08 +0000
parents 5b4c812b448e
children 021492db4aad
line wrap: on
line diff
--- a/gpp/forums/forms.py	Sun Aug 30 19:58:42 2009 +0000
+++ b/gpp/forums/forms.py	Sat Sep 05 20:47:08 2009 +0000
@@ -7,20 +7,17 @@
 from forums.models import Post
 
 
-class TopicForm(forms.ModelForm):
-    """Form for creating a new topic."""
-    
-    class Meta:
-        model = Topic
-        fields = ('name', )
+class PostForm(forms.Form):
+    """Form for creating a new post."""
+    body = forms.CharField(label='', widget=forms.Textarea)
 
-
-class PostForm(forms.ModelForm):
-    """Form for creating a new post."""
-    
-    class Meta:
-        model = Post
-        fields = ('body', )
+    def save(self, topic, user, ip=None):
+        """
+        Creates a new post from the form data and supplied arguments.
+        """
+        post = Post(topic=topic, user=user, body=self.cleaned_data['body'],
+                user_ip=user_ip)
+        post.save()
 
 
 class NewTopicForm(forms.Form):
@@ -31,7 +28,7 @@
     def save(self, forum, user, ip=None):
         """
         Creates the new Topic and first Post from the form data and supplied
-        forum and user objects.
+        arguments.
         """
         topic = Topic(forum=forum,
                 name=self.cleaned_data['name'],