Skip to content

Commit

Permalink
Adjust current_position_nonexec logic
Browse files Browse the repository at this point in the history
When filtering exec members from current staff,
only consider _current_ exec committee titles.
  • Loading branch information
rlskoeser committed Aug 12, 2021
1 parent 52c122b commit f61bcb8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cdhweb/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def project_manager_years(self):
def _current_position_query(self):
# query to find a person with a current cdh position
# person *has* a position and it has no end date or date after today
return models.Q(positions__isnull=False) & (
today = date.today()
return models.Q(positions__start_date__lte=today) & (
models.Q(positions__end_date__isnull=True)
| models.Q(positions__end_date__gte=date.today())
)
Expand Down Expand Up @@ -220,10 +221,12 @@ def current_position(self):

def current_position_nonexec(self):
"""Return profiles for users with a current position, excluding
executive committee positions."""
return self.filter(
models.Q(self._current_position_query())
& ~models.Q(positions__title__title__in=self.exec_committee_titles)
current executive committee positions."""
cpq = self._current_position_query()
return (
self.filter(cpq)
.annotate(current_position_title=models.F("positions__title__title"))
.exclude(current_position_title__in=self.exec_committee_titles)
)

def order_by_position(self):
Expand Down

0 comments on commit f61bcb8

Please sign in to comment.