1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import django.forms
from django.contrib.auth.models import User
from postgresqleu.util.backendforms import BackendForm, BackendBeforeNewForm
from postgresqleu.util.fields import UserModelChoiceField
from postgresqleu.newsevents.models import News, NewsPosterProfile
from postgresqleu.confreg.backendforms import BackendTweetQueueForm
class BackendNewsForm(BackendForm):
list_fields = ['datetime', 'title', 'author', ]
queryset_select_related = ['author', ]
markdown_fields = ['summary', ]
class Meta:
model = News
fields = ['title', 'datetime', 'author', 'summary', 'highpriorityuntil',
'inrss', 'inarchive', ]
@classmethod
def get_column_filters(cls, conference):
return {
'Author': NewsPosterProfile.objects.all(),
}
class BackendNewAuthorForm(BackendBeforeNewForm):
helplink = 'news#authors'
user = UserModelChoiceField(queryset=User.objects.order_by('username'))
selectize_single_fields = {
'user': None,
}
def get_newform_data(self):
return self.cleaned_data['user'].pk
class BackendAuthorForm(BackendForm):
list_fields = ['author', 'fullname', 'urlname', 'canpostglobal', ]
form_before_new = BackendNewAuthorForm
class Meta:
model = NewsPosterProfile
fields = ['fullname', 'urlname', 'canpostglobal', ]
def fix_fields(self):
if self.newformdata:
self.instance.author = User.objects.get(pk=self.newformdata)
# We must force the system to do an insert at this point. Since we set 'pk',
# it will otherwise think it's an edit, do an UPDATE, and fail.
self.force_insert = True
class BackendPostQueueForm(BackendTweetQueueForm):
verbose_name = 'news social media post'
verbose_name_plural = 'news social media posts'
|