Skip to content

Commit 9e36246

Browse files
committed
Rewrote a function to be more readable and actually do the right thing. This moved some filtering from database into code, but it seems acceptable here.
- Legacy-Id: 16013
1 parent 267e9ee commit 9e36246

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

ietf/group/utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ def construct_group_menu_context(request, group, selected, group_type, others):
254254

255255

256256
def group_features_group_filter(groups, person, feature):
257-
"""This returns a queryset of groups filtered such that the given person has
257+
"""This returns a list of groups filtered such that the given person has
258258
a role listed in the given feature for each group."""
259-
type_slugs = set(groups.values_list('type__slug', flat=True))
260-
group_types = GroupTypeName.objects.filter(slug__in=type_slugs)
261-
if not group_types.exists():
262-
return groups.none()
263-
q = reduce(lambda a,b:a|b, [ Q(role__person=person, role__name__slug__in=getattr(t.features, feature)) for t in group_types ])
264-
return groups.filter(q)
259+
feature_groups = []
260+
for g in groups:
261+
for r in person.role_set.filter(group=g):
262+
if r.name.slug in getattr(r.group.type.features, feature):
263+
feature_groups.append(g)
264+
return feature_groups
265265

266266
def group_features_role_filter(roles, person, feature):
267267
type_slugs = set(roles.values_list('group__type__slug', flat=True))

0 commit comments

Comments
 (0)