Skip to content

Commit

Permalink
Add SQL queries for conditional states (#2013)
Browse files Browse the repository at this point in the history
  • Loading branch information
jace authored Apr 8, 2024
1 parent b9f1763 commit f95564e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions funnel/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ def ticket_followers(self) -> Query[Account]:
'ACTIVE_AND_PUBLIC',
profile_state.PUBLIC,
lambda account: bool(account.state.ACTIVE),
lambda account: account.state.ACTIVE.__clause_element__(),
)

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions funnel/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,12 +634,14 @@ def rooms(self) -> list[VenueRoom]:
'HAS_PROPOSALS',
cfp_state.ANY,
lambda project: db.session.query(project.proposals.exists()).scalar(),
lambda project: project.proposals.exists(),
label=('has_proposals', __("Has submissions")),
)
cfp_state.add_conditional_state(
'HAS_SESSIONS',
cfp_state.ANY,
lambda project: db.session.query(project.sessions.exists()).scalar(),
lambda project: project.sessions.exists(),
label=('has_sessions', __("Has sessions")),
)
cfp_state.add_conditional_state(
Expand Down
3 changes: 3 additions & 0 deletions funnel/models/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ def __format__(self, format_spec: str) -> str:
'SCHEDULED',
state.CONFIRMED,
lambda proposal: proposal.session is not None and proposal.session.scheduled,
lambda proposal: sa.and_(
proposal.session.isnot(None), proposal.session.scheduled
),
label=('scheduled', __("Confirmed & scheduled")),
)

Expand Down

0 comments on commit f95564e

Please sign in to comment.