Skip to content

Commit

Permalink
fixing viewer access on scheduled survey (#1993)
Browse files Browse the repository at this point in the history
  • Loading branch information
VineetBala-AOT authored Aug 10, 2023
1 parent b0efba5 commit 367d081
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions met-api/src/met_api/models/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,16 @@ def unlink_survey(cls, survey_id) -> Optional[Survey or None]:
@staticmethod
def _filter_accessible_surveys(query, assigned_engagements: list[int]):
filter_conditions = [
# Exclude draft engagements that the user is not assigned to
Engagement.status_id != Status.Draft.value,
# Scheduled surveys are still not viewable
Engagement.status_id != Status.Scheduled.value,
# Include all assigned engagements even if its draft
# Exclude draft engagements and scheduled engagements that the user is not assigned to
and_(
Engagement.status_id != Status.Draft.value,
Engagement.status_id != Status.Scheduled.value
),
# Include all assigned engagements even if they are in draft status
Engagement.id.in_(assigned_engagements),
# Include Un-linked surveys
Survey.engagement_id.is_(None)]
Survey.engagement_id.is_(None)
]
query = query.filter(or_(*filter_conditions))
return query

Expand Down

0 comments on commit 367d081

Please sign in to comment.