This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aanmaken subjects en projects enpoints die niet meer verbonden zijn a…
…an student #45
- Loading branch information
Showing
4 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from fastapi import APIRouter, Depends | ||
from sqlalchemy.orm import Session | ||
|
||
from db.sessions import get_session | ||
from domain.logic.project import get_project | ||
from domain.models.ProjectDataclass import ProjectDataclass | ||
|
||
project_router = APIRouter() | ||
|
||
|
||
@project_router.get("/projects/{project_id}") | ||
def get_subject_project(project_id: int, session: Session = Depends(get_session)) -> ProjectDataclass: | ||
return get_project(session, project_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from fastapi import APIRouter, Depends | ||
from sqlalchemy.orm import Session | ||
|
||
from db.sessions import get_session | ||
from domain.logic.project import get_projects_of_subject | ||
from domain.logic.subject import get_subject | ||
from domain.models.ProjectDataclass import ProjectDataclass | ||
from domain.models.SubjectDataclass import SubjectDataclass | ||
from routes.dependencies.role_dependencies import get_authenticated_student | ||
|
||
subject_router = APIRouter() | ||
|
||
|
||
@subject_router.get("/subjects/{subject_id}", dependencies=[Depends(get_authenticated_student)]) | ||
def subject_get(subject_id: int, session: Session = Depends(get_session)) -> SubjectDataclass: | ||
return get_subject(session, subject_id) | ||
|
||
|
||
@subject_router.get("/subjects/{subject_id}/projects", dependencies=[Depends(get_authenticated_student)]) | ||
def get_subject_projects(subject_id: int, session: Session = Depends(get_session)) -> list[ProjectDataclass]: | ||
return get_projects_of_subject(session, subject_id) |