Skip to content

Commit

Permalink
add the ability to filter oganization membership by the division the …
Browse files Browse the repository at this point in the history
…people represent
  • Loading branch information
twentyforty committed Nov 12, 2021
1 parent f157dd9 commit df86629
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion openstates/data/models/people_orgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit df86629

Please sign in to comment.