Mercurial > public > sg101
comparison gpp/forums/forms.py @ 460:2ff5f4c1476d
Fixing #221. Found some additional cases where the forum moderator check was failing. Replaced this code with calls to the new permissions module.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 03 Jul 2011 19:35:09 +0000 |
parents | 26fc9ac9a0eb |
children | 3b30286adba5 |
comparison
equal
deleted
inserted
replaced
459:9d3bd7304050 | 460:2ff5f4c1476d |
---|---|
6 | 6 |
7 from forums.models import Forum | 7 from forums.models import Forum |
8 from forums.models import Topic | 8 from forums.models import Topic |
9 from forums.models import Post | 9 from forums.models import Post |
10 from forums.attachments import AttachmentProcessor | 10 from forums.attachments import AttachmentProcessor |
11 import forums.permissions as perms | |
11 | 12 |
12 | 13 |
13 class NewPostForm(forms.Form): | 14 class NewPostForm(forms.Form): |
14 """Form for creating a new post.""" | 15 """Form for creating a new post.""" |
15 body = forms.CharField(label='', | 16 body = forms.CharField(label='', |
83 def __init__(self, user, forum, *args, **kwargs): | 84 def __init__(self, user, forum, *args, **kwargs): |
84 super(NewTopicForm, self).__init__(*args, **kwargs) | 85 super(NewTopicForm, self).__init__(*args, **kwargs) |
85 self.user = user | 86 self.user = user |
86 self.forum = forum | 87 self.forum = forum |
87 | 88 |
88 if user.is_superuser or user in forum.moderators.all(): | 89 if perms.can_moderate(forum, user): |
89 self.fields['sticky'] = forms.BooleanField(required=False) | 90 self.fields['sticky'] = forms.BooleanField(required=False) |
90 self.fields['locked'] = forms.BooleanField(required=False) | 91 self.fields['locked'] = forms.BooleanField(required=False) |
91 self.has_mod_fields = True | 92 self.has_mod_fields = True |
92 | 93 |
93 attachments = args[0].getlist('attachment') if len(args) else [] | 94 attachments = args[0].getlist('attachment') if len(args) else [] |