add visible field to form
This commit is contained in:
@@ -7,12 +7,20 @@ def get_all(
|
||||
seasons: list[str],
|
||||
productors: list[str],
|
||||
current_season: bool,
|
||||
user: models.User = None
|
||||
) -> list[models.FormPublic]:
|
||||
statement = select(models.Form)
|
||||
if user:
|
||||
statement = statement\
|
||||
.join(models.Productor, models.Form.productor_id == models.Productor.id)\
|
||||
.where(models.Productor.type.in_([r.name for r in user.roles]))\
|
||||
.distinct()
|
||||
if len(seasons) > 0:
|
||||
statement = statement.where(models.Form.season.in_(seasons))
|
||||
if len(productors) > 0:
|
||||
statement = statement.join(models.Productor).where(models.Productor.name.in_(productors))
|
||||
if not user:
|
||||
statement = statement.where(models.Form.visible == True)
|
||||
if current_season:
|
||||
subquery = (
|
||||
select(
|
||||
@@ -29,6 +37,8 @@ def get_all(
|
||||
(models.Productor.type == subquery.c.type) &
|
||||
(models.Form.start == subquery.c.max_start)
|
||||
)
|
||||
if not user:
|
||||
statement = statement.where(models.Form.visible == True)
|
||||
return session.exec(statement.order_by(models.Form.name)).all()
|
||||
return session.exec(statement.order_by(models.Form.name)).all()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user