comparison gpp/forums/forms.py @ 469:3b30286adba5

Smarter search index updating for forums. This work is for #227.
author Brian Neal <bgneal@gmail.com>
date Wed, 17 Aug 2011 01:02:08 +0000
parents 2ff5f4c1476d
children bbbc357ac5f3
comparison
equal deleted inserted replaced
468:ad4b63fbc584 469:3b30286adba5
1 """ 1 """
2 Forms for the forums application. 2 Forms for the forums application.
3
3 """ 4 """
4 from django import forms 5 from django import forms
5 from django.conf import settings 6 from django.conf import settings
6 7
7 from forums.models import Forum 8 from forums.models import Forum
8 from forums.models import Topic 9 from forums.models import Topic
9 from forums.models import Post 10 from forums.models import Post
10 from forums.attachments import AttachmentProcessor 11 from forums.attachments import AttachmentProcessor
11 import forums.permissions as perms 12 import forums.permissions as perms
13 from forums.signals import notify_new_topic, notify_new_post
12 14
13 15
14 class NewPostForm(forms.Form): 16 class NewPostForm(forms.Form):
15 """Form for creating a new post.""" 17 """Form for creating a new post."""
16 body = forms.CharField(label='', 18 body = forms.CharField(label='',
53 """ 55 """
54 post = Post(topic=self.topic, user=user, body=self.cleaned_data['body'], 56 post = Post(topic=self.topic, user=user, body=self.cleaned_data['body'],
55 user_ip=ip) 57 user_ip=ip)
56 post.save() 58 post.save()
57 self.attach_proc.save_attachments(post) 59 self.attach_proc.save_attachments(post)
60 notify_new_post(post)
58 return post 61 return post
59 62
60 63
61 class NewTopicForm(forms.Form): 64 class NewTopicForm(forms.Form):
62 """ 65 """
129 user_ip=ip) 132 user_ip=ip)
130 post.save() 133 post.save()
131 134
132 self.attach_proc.save_attachments(post) 135 self.attach_proc.save_attachments(post)
133 136
137 notify_new_topic(topic)
138 notify_new_post(post)
139
134 return topic 140 return topic
135 141
136 142
137 class PostForm(forms.ModelForm): 143 class PostForm(forms.ModelForm):
138 """ 144 """