Skip to content

Commit f9cd721

Browse files
committed
Updated some functions and views in secr/srec/ to use GroupFeatures instead of harcoded lists of group types.
- Legacy-Id: 16301
1 parent da5ff11 commit f9cd721

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

ietf/secr/sreq/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ def main(request):
491491
)
492492

493493
meeting = get_meeting()
494-
scheduled_groups,unscheduled_groups = groups_by_session(request.user, meeting, types=['wg','rg','ag'])
494+
495+
scheduled_groups, unscheduled_groups = groups_by_session(request.user, meeting)
495496

496497
# warn if there are no associated groups
497498
if not scheduled_groups and not unscheduled_groups:

ietf/secr/utils/group.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright The IETF Trust 2013-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
14
# Python imports
25
import os
36

@@ -6,7 +9,7 @@
69
from django.core.exceptions import ObjectDoesNotExist
710

811
# Datatracker imports
9-
from ietf.group.models import Group
12+
from ietf.group.models import Group, GroupFeatures
1013
from ietf.meeting.models import Session
1114
from ietf.ietfauth.utils import has_role
1215

@@ -49,9 +52,8 @@ def get_my_groups(user,conclude=False):
4952
states = ['bof','proposed','active']
5053
if conclude:
5154
states.extend(['conclude','bof-conc'])
52-
types = ['wg','rg','ag','team','iab']
53-
54-
all_groups = Group.objects.filter(type__in=types,state__in=states).order_by('acronym')
55+
56+
all_groups = Group.objects.filter(type__features__has_meetings=True, state__in=states).order_by('acronym')
5557
if user == None or has_role(user,'Secretariat'):
5658
return all_groups
5759

@@ -94,8 +96,10 @@ def groups_by_session(user, meeting, types=None):
9496
if group.state_id not in ('conclude','bof-conc'):
9597
groups_no_session.append(group)
9698

97-
if types:
98-
groups_session = filter(lambda x: x.type_id in types,groups_session)
99-
groups_no_session = filter(lambda x: x.type_id in types,groups_no_session)
99+
if not types:
100+
types = GroupFeatures.objects.filter(has_meetings=True).values_list('type', flat=True)
101+
102+
groups_session = filter(lambda g: g.type_id in types, groups_session)
103+
groups_no_session = filter(lambda g: g.type_id in types, groups_no_session)
100104

101105
return groups_session, groups_no_session

0 commit comments

Comments
 (0)