Mercurial > public > sg101
comparison gpp/forums/forms.py @ 95:23035afdeae8
Forums: use markitup editor on forums post forms.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 13 Sep 2009 18:05:18 +0000 |
parents | 021492db4aad |
children | 93d9e74a471e |
comparison
equal
deleted
inserted
replaced
94:806399f3b950 | 95:23035afdeae8 |
---|---|
1 """ | 1 """ |
2 Forms for the forums application. | 2 Forms for the forums application. |
3 """ | 3 """ |
4 from django import forms | 4 from django import forms |
5 from django.conf import settings | |
5 | 6 |
6 from forums.models import Topic | 7 from forums.models import Topic |
7 from forums.models import Post | 8 from forums.models import Post |
8 | 9 |
9 | 10 |
12 body = forms.CharField(label='', widget=forms.Textarea) | 13 body = forms.CharField(label='', widget=forms.Textarea) |
13 topic_id = forms.IntegerField(widget=forms.HiddenInput) | 14 topic_id = forms.IntegerField(widget=forms.HiddenInput) |
14 topic = None | 15 topic = None |
15 | 16 |
16 class Media: | 17 class Media: |
17 js = ('js/forums.js', ) | 18 css = { |
19 'all': settings.GPP_THIRD_PARTY_CSS['markitup'], | |
20 } | |
21 js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ | |
22 ('js/forums.js', ) | |
18 | 23 |
19 def clean_topic_id(self): | 24 def clean_topic_id(self): |
20 id = self.cleaned_data['topic_id'] | 25 id = self.cleaned_data['topic_id'] |
21 print '*********', id | 26 print '*********', id |
22 try: | 27 try: |
36 return post | 41 return post |
37 | 42 |
38 | 43 |
39 class NewTopicForm(forms.Form): | 44 class NewTopicForm(forms.Form): |
40 """Form for creating a new topic and 1st post to that topic.""" | 45 """Form for creating a new topic and 1st post to that topic.""" |
41 name = forms.CharField(label='Subject', max_length=255) | 46 name = forms.CharField(label='Subject', max_length=255, |
47 widget=forms.TextInput(attrs={'size': 64})) | |
42 body = forms.CharField(label='', widget=forms.Textarea) | 48 body = forms.CharField(label='', widget=forms.Textarea) |
49 | |
50 class Media: | |
51 css = { | |
52 'all': settings.GPP_THIRD_PARTY_CSS['markitup'], | |
53 } | |
54 js = settings.GPP_THIRD_PARTY_JS['markitup'] + \ | |
55 ('js/forums.js', ) | |
43 | 56 |
44 def save(self, forum, user, ip=None): | 57 def save(self, forum, user, ip=None): |
45 """ | 58 """ |
46 Creates the new Topic and first Post from the form data and supplied | 59 Creates the new Topic and first Post from the form data and supplied |
47 arguments. | 60 arguments. |