|
14 | 14 | from django.conf import settings |
15 | 15 | from django.core import validators |
16 | 16 | from django.core.exceptions import ValidationError |
17 | | -from django.db.models import Q |
18 | 17 | from django.forms import BaseInlineFormSet |
19 | 18 | from django.utils.functional import cached_property |
20 | 19 |
|
21 | 20 | import debug # pyflakes:ignore |
22 | 21 |
|
23 | 22 | from ietf.doc.models import Document, DocAlias, State, NewRevisionDocEvent |
24 | | -from ietf.group.models import Group, GroupFeatures |
25 | | -from ietf.ietfauth.utils import has_role |
| 23 | +from ietf.group.models import Group |
| 24 | +from ietf.group.utils import groups_managed_by |
26 | 25 | from ietf.meeting.models import Session, Meeting, Schedule, countries, timezones, TimeSlot, Room |
27 | 26 | from ietf.meeting.helpers import get_next_interim_number, make_materials_directories |
28 | 27 | from ietf.meeting.helpers import is_interim_meeting_approved, get_next_agenda_name |
@@ -106,10 +105,7 @@ def clean(self): |
106 | 105 |
|
107 | 106 | class InterimMeetingModelForm(forms.ModelForm): |
108 | 107 | group = GroupModelChoiceField( |
109 | | - queryset=Group.objects.filter( |
110 | | - type_id__in=GroupFeatures.objects.filter( |
111 | | - has_meetings=True |
112 | | - ).values_list('type_id',flat=True), |
| 108 | + queryset=Group.objects.with_meetings().filter( |
113 | 109 | state__in=('active', 'proposed', 'bof') |
114 | 110 | ).order_by('acronym'), |
115 | 111 | required=False, |
@@ -187,24 +183,14 @@ def is_virtual(self): |
187 | 183 | return True |
188 | 184 |
|
189 | 185 | def set_group_options(self): |
190 | | - '''Set group options based on user accessing the form''' |
191 | | - if has_role(self.user, "Secretariat"): |
192 | | - return # don't reduce group options |
193 | | - q_objects = Q() |
194 | | - if has_role(self.user, "Area Director"): |
195 | | - q_objects.add(Q(type__in=["wg", "ag", "team"], state__in=("active", "proposed", "bof")), Q.OR) |
196 | | - if has_role(self.user, "IRTF Chair"): |
197 | | - q_objects.add(Q(type__in=["rg", "rag"], state__in=("active", "proposed")), Q.OR) |
198 | | - if has_role(self.user, "WG Chair"): |
199 | | - q_objects.add(Q(type="wg", state__in=("active", "proposed", "bof"), role__person=self.person, role__name="chair"), Q.OR) |
200 | | - if has_role(self.user, "RG Chair"): |
201 | | - q_objects.add(Q(type="rg", state__in=("active", "proposed"), role__person=self.person, role__name="chair"), Q.OR) |
202 | | - if has_role(self.user, "Program Lead") or has_role(self.user, "Program Chair"): |
203 | | - q_objects.add(Q(type="program", state__in=("active", "proposed"), role__person=self.person, role__name__in=["chair", "lead"]), Q.OR) |
204 | | - |
205 | | - queryset = Group.objects.filter(q_objects).distinct().order_by('acronym') |
| 186 | + """Set group options based on user accessing the form""" |
| 187 | + queryset = groups_managed_by( |
| 188 | + self.user, |
| 189 | + Group.objects.with_meetings(), |
| 190 | + ).filter( |
| 191 | + state_id__in=['active', 'proposed', 'bof'] |
| 192 | + ).order_by('acronym') |
206 | 193 | self.fields['group'].queryset = queryset |
207 | | - |
208 | 194 | # if there's only one possibility make it the default |
209 | 195 | if len(queryset) == 1: |
210 | 196 | self.fields['group'].initial = queryset[0] |
|
0 commit comments