|
5 | 5 |
|
6 | 6 | from django import forms |
7 | 7 | from django.core.validators import ValidationError |
| 8 | +from django.db.models import Q |
8 | 9 | from django.forms.fields import Field |
9 | 10 | from django.utils.encoding import force_text |
10 | 11 | from django.utils import six |
@@ -190,14 +191,17 @@ def set_group_options(self): |
190 | 191 | '''Set group options based on user accessing the form''' |
191 | 192 | if has_role(self.user, "Secretariat"): |
192 | 193 | return # don't reduce group options |
| 194 | + q_objects = Q() |
193 | 195 | if has_role(self.user, "Area Director"): |
194 | | - queryset = Group.objects.filter(type="wg", state__in=("active", "proposed", "bof")).order_by('acronym') |
195 | | - elif has_role(self.user, "IRTF Chair"): |
196 | | - queryset = Group.objects.filter(type="rg", state__in=("active", "proposed")).order_by('acronym') |
197 | | - elif has_role(self.user, "WG Chair"): |
198 | | - queryset = Group.objects.filter(type="wg", state__in=("active", "proposed", "bof"), role__person=self.person, role__name="chair").distinct().order_by('acronym') |
199 | | - elif has_role(self.user, "RG Chair"): |
200 | | - queryset = Group.objects.filter(type="rg", state__in=("active", "proposed"), role__person=self.person, role__name="chair").distinct().order_by('acronym') |
| 196 | + q_objects.add(Q(type="wg", state__in=("active", "proposed", "bof")), Q.OR) |
| 197 | + if has_role(self.user, "IRTF Chair"): |
| 198 | + q_objects.add(Q(type="rg", state__in=("active", "proposed")), Q.OR) |
| 199 | + if has_role(self.user, "WG Chair"): |
| 200 | + q_objects.add(Q(type="wg", state__in=("active", "proposed", "bof"), role__person=self.person, role__name="chair"), Q.OR) |
| 201 | + if has_role(self.user, "RG Chair"): |
| 202 | + q_objects.add(Q(type="rg", state__in=("active", "proposed"), role__person=self.person, role__name="chair"), Q.OR) |
| 203 | + |
| 204 | + queryset = Group.objects.filter(q_objects).distinct().order_by('acronym') |
201 | 205 | self.fields['group'].queryset = queryset |
202 | 206 |
|
203 | 207 | # if there's only one possibility make it the default |
|
0 commit comments