From c237e99500390ef43e8984ec8f8741fe45e05255 Mon Sep 17 00:00:00 2001 From: drieshuybens Date: Thu, 23 May 2024 12:10:57 +0200 Subject: [PATCH] publish date checks --- backend/src/project/service.py | 7 ++----- backend/src/subject/router.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/backend/src/project/service.py b/backend/src/project/service.py index 15dadee5..bb6b5456 100644 --- a/backend/src/project/service.py +++ b/backend/src/project/service.py @@ -33,15 +33,12 @@ async def get_project(db: AsyncSession, project_id: int) -> Project: return result.scalars().first() -async def get_projects_by_user(db: AsyncSession, user_id: str) -> tuple: - now_utc = datetime.now(timezone.utc) +async def get_projects_by_user(db: AsyncSession, user_id: str) -> tuple[Sequence[Project], Sequence[Project]]: student_result = await db.execute( select(Project) .join(Subject, Project.subject_id == Subject.id) .join(StudentSubject, StudentSubject.c.subject_id == Subject.id) - .where( - (StudentSubject.c.uid == user_id) - ) + .where(StudentSubject.c.uid == user_id) ) instructor_result = await db.execute( select(Project) diff --git a/backend/src/subject/router.py b/backend/src/subject/router.py index 5b22838f..15bd9f67 100644 --- a/backend/src/subject/router.py +++ b/backend/src/subject/router.py @@ -181,6 +181,6 @@ async def list_projects( if not await has_subject_privileges(subject_id, user, db): now = datetime.now(timezone.utc) projects.projects = [ - project for project in projects.projects if project.publish_date <= now and project.is_visible] + project for project in projects.projects if project.publish_date <= now] return projects