Skip to content

Commit

Permalink
Merge pull request #373 from Princeton-CDH/bugfix/staff-nonexec-fix
Browse files Browse the repository at this point in the history
Fix current_position_nonexec filter so it only filters out current exec positions, not past
  • Loading branch information
rlskoeser authored Aug 16, 2021
2 parents a3a3bb9 + f61bcb8 commit 7c66f36
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 7c66f36

Please sign in to comment.