Mercurial > public > sg101
comparison forums/forms.py @ 951:5366c29d6dce
Django's SortedDict is gone. Use OrderedDict instead.
For Django 1.7.8 upgrade.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 16 May 2015 18:51:12 -0500 |
parents | 71d17d267e27 |
children | 71a671dab55d 4619290d171d |
comparison
equal
deleted
inserted
replaced
950:c614edb5b51e | 951:5366c29d6dce |
---|---|
1 """ | 1 """ |
2 Forms for the forums application. | 2 Forms for the forums application. |
3 | 3 |
4 """ | 4 """ |
5 from collections import OrderedDict | |
6 | |
5 from django import forms | 7 from django import forms |
6 from django.conf import settings | 8 from django.conf import settings |
7 | 9 |
8 from forums.models import Forum | 10 from forums.models import Forum |
9 from forums.models import Topic | 11 from forums.models import Topic |
159 | 161 |
160 def __init__(self, *args, **kwargs): | 162 def __init__(self, *args, **kwargs): |
161 topic_name = kwargs.pop('topic_name', None) | 163 topic_name = kwargs.pop('topic_name', None) |
162 super(PostForm, self).__init__(*args, **kwargs) | 164 super(PostForm, self).__init__(*args, **kwargs) |
163 | 165 |
164 if topic_name is not None: # this is a "first post" | 166 if topic_name is not None: |
165 self.fields.insert(0, 'name', forms.CharField(label='Subject', | 167 # this is a "first post", add a field for a topic name |
166 max_length=255, | 168 new_fields = OrderedDict(name=forms.CharField( |
167 widget=forms.TextInput(attrs={'size': 64}))) | 169 label='Subject', max_length=255, |
170 widget=forms.TextInput(attrs={ | |
171 'class': 'title', | |
172 'style': 'width: 90%', | |
173 }))) | |
174 new_fields.update(self.fields) | |
175 self.fields = new_fields | |
168 self.initial['name'] = topic_name | 176 self.initial['name'] = topic_name |
169 | 177 |
170 attachments = args[0].getlist('attachment') if len(args) else [] | 178 attachments = args[0].getlist('attachment') if len(args) else [] |
171 self.attach_proc = AttachmentProcessor(attachments) | 179 self.attach_proc = AttachmentProcessor(attachments) |
172 | 180 |