Skip to content

Commit

Permalink
publish date checks
Browse files Browse the repository at this point in the history
  • Loading branch information
DRIESASTER committed May 23, 2024
1 parent 87dc0f5 commit c237e99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions backend/src/project/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion backend/src/subject/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c237e99

Please sign in to comment.