-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.py
More file actions
37 lines (31 loc) · 1.18 KB
/
forms.py
File metadata and controls
37 lines (31 loc) · 1.18 KB
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
from django import forms
from plugins.vae_workflow import models
class ClaimForm(forms.ModelForm):
class Meta:
model = models.EditorClaim
fields = ('notes',)
widgets = {
'notes': forms.Textarea(attrs={'rows': 3}),
}
class AddPoolMemberForm(forms.Form):
account = forms.ModelChoiceField(
queryset=None,
label='Section Editor',
help_text='Select a section editor to add to the VAE pool.',
)
def __init__(self, *args, journal=None, **kwargs):
super().__init__(*args, **kwargs)
if journal:
from core.models import Account, AccountRole
already_in_pool = models.VAEPoolMember.objects.filter(
journal=journal,
).values_list('account_id', flat=True)
section_editor_ids = AccountRole.objects.filter(
journal=journal,
role__slug='section-editor',
).values_list('user_id', flat=True)
self.fields['account'].queryset = Account.objects.filter(
pk__in=section_editor_ids,
).exclude(
pk__in=already_in_pool,
).order_by('last_name', 'first_name')