From df86629c9fb1d0f120711f5fa732ebebfc2ece57 Mon Sep 17 00:00:00 2001 From: Aly Ibrahim Date: Fri, 12 Nov 2021 17:26:55 -0500 Subject: [PATCH] add the ability to filter oganization membership by the division the people represent --- openstates/data/models/people_orgs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openstates/data/models/people_orgs.py b/openstates/data/models/people_orgs.py index b5825d51f..e8bfcc811 100644 --- a/openstates/data/models/people_orgs.py +++ b/openstates/data/models/people_orgs.py @@ -117,7 +117,7 @@ def __str__(self): class PersonQuerySet(QuerySet): - def member_of(self, organization_name, current_only=True, post=None): + def member_of(self, organization_name, current_only=True, post=None, division_id=None): if organization_name.startswith("ocd-organization/"): org_filter = Q(memberships__organization_id=organization_name) else: @@ -132,6 +132,8 @@ def member_of(self, organization_name, current_only=True, post=None): ) & Q(memberships__end_date="") | Q(memberships__end_date__gte=today) if post: org_filter &= Q(memberships__post__label=post) + if division_id: + org_filter &= Q(memberships__post__division_id=division_id) return qs.filter(org_filter).distinct() def active(self):