Mercurial > public > sg101
comparison forums/forms.py @ 1017:21c592cac71c
ManifestStaticFilesStorage: stop using form Media.
It's okay for the admin, but not for user facing stuff.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 06 Dec 2015 14:48:30 -0600 |
parents | 4619290d171d |
children |
comparison
equal
deleted
inserted
replaced
1016:fd70e9d547ed | 1017:21c592cac71c |
---|---|
3 | 3 |
4 """ | 4 """ |
5 from collections import OrderedDict | 5 from collections import OrderedDict |
6 | 6 |
7 from django import forms | 7 from django import forms |
8 from django.conf import settings | |
9 | 8 |
10 from forums.models import Forum | 9 from forums.models import Forum |
11 from forums.models import Topic | 10 from forums.models import Topic |
12 from forums.models import Post | 11 from forums.models import Post |
13 from forums.attachments import AttachmentProcessor | 12 from forums.attachments import AttachmentProcessor |
16 from core.html import ImageCheckError | 15 from core.html import ImageCheckError |
17 from core.html import image_check | 16 from core.html import image_check |
18 from core.markup import site_markup | 17 from core.markup import site_markup |
19 | 18 |
20 | 19 |
21 FORUMS_FORM_CSS = { | |
22 'all': (settings.GPP_THIRD_PARTY_CSS['markitup'] + | |
23 settings.GPP_THIRD_PARTY_CSS['jquery-ui']) | |
24 } | |
25 FORUMS_FORM_JS = ( | |
26 settings.GPP_THIRD_PARTY_JS['markitup'] + | |
27 settings.GPP_THIRD_PARTY_JS['jquery-ui'] + | |
28 ['js/jquery.form.min.js', 'js/forums.js'] | |
29 ) | |
30 | |
31 | |
32 class NewPostForm(forms.Form): | 20 class NewPostForm(forms.Form): |
33 """Form for creating a new post.""" | 21 """Form for creating a new post.""" |
34 body = forms.CharField(label='', | 22 body = forms.CharField(label='', |
35 required=False, | 23 required=False, |
36 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) | 24 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) |
37 topic_id = forms.IntegerField(widget=forms.HiddenInput) | 25 topic_id = forms.IntegerField(widget=forms.HiddenInput) |
38 topic = None | 26 topic = None |
39 | 27 |
40 class Media: | |
41 css = FORUMS_FORM_CSS | |
42 js = FORUMS_FORM_JS | |
43 | |
44 def __init__(self, *args, **kwargs): | 28 def __init__(self, *args, **kwargs): |
45 super(NewPostForm, self).__init__(*args, **kwargs) | 29 super(NewPostForm, self).__init__(*args, **kwargs) |
46 attachments = args[0].getlist('attachment') if len(args) else [] | 30 attachments = args[0].getlist('attachment') if len(args) else [] |
47 self.attach_proc = AttachmentProcessor(attachments) | 31 self.attach_proc = AttachmentProcessor(attachments) |
48 | 32 |
92 body = forms.CharField(label='', required=False, | 76 body = forms.CharField(label='', required=False, |
93 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) | 77 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) |
94 user = None | 78 user = None |
95 forum = None | 79 forum = None |
96 has_mod_fields = False | 80 has_mod_fields = False |
97 | |
98 class Media: | |
99 css = FORUMS_FORM_CSS | |
100 js = FORUMS_FORM_JS | |
101 | 81 |
102 def __init__(self, user, forum, *args, **kwargs): | 82 def __init__(self, user, forum, *args, **kwargs): |
103 super(NewTopicForm, self).__init__(*args, **kwargs) | 83 super(NewTopicForm, self).__init__(*args, **kwargs) |
104 self.user = user | 84 self.user = user |
105 self.forum = forum | 85 self.forum = forum |
173 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) | 153 widget=forms.Textarea(attrs={'class': 'markItUp smileyTarget'})) |
174 | 154 |
175 class Meta: | 155 class Meta: |
176 model = Post | 156 model = Post |
177 fields = ('body', ) | 157 fields = ('body', ) |
178 | |
179 class Media: | |
180 css = FORUMS_FORM_CSS | |
181 js = FORUMS_FORM_JS | |
182 | 158 |
183 def __init__(self, *args, **kwargs): | 159 def __init__(self, *args, **kwargs): |
184 topic_name = kwargs.pop('topic_name', None) | 160 topic_name = kwargs.pop('topic_name', None) |
185 super(PostForm, self).__init__(*args, **kwargs) | 161 super(PostForm, self).__init__(*args, **kwargs) |
186 | 162 |