Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
rubben-88 committed Mar 19, 2024
1 parent 7321148 commit 5b32f0e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 17 deletions.
2 changes: 1 addition & 1 deletion backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from routes.project import project_router
from routes.student import student_router
from routes.subject import subject_router
from routes.tags.swagger_tags import tags_metadata
from routes.teacher import teacher_router
from routes.user import users_router
from routes.tags.swagger_tags import tags_metadata

app = FastAPI(docs_url="/api/docs", openapi_tags=tags_metadata)

Expand Down
18 changes: 9 additions & 9 deletions backend/routes/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@


@project_router.get(
"/projects/{project_id}",
dependencies=[Depends(ensure_user_authorized_for_project)],
"/projects/{project_id}",
dependencies=[Depends(ensure_user_authorized_for_project)],
tags=[Tags.PROJECT],
summary="Get a certain project."
summary="Get a certain project.",
)
def project_get(
project_id: int,
Expand All @@ -30,10 +30,10 @@ def project_get(


@project_router.get(
"/projects/{project_id}/groups",
dependencies=[Depends(ensure_user_authorized_for_project)],
"/projects/{project_id}/groups",
dependencies=[Depends(ensure_user_authorized_for_project)],
tags=[Tags.PROJECT],
summary="Get all formed groups of a certain project."
summary="Get all formed groups of a certain project.",
)
def project_get_groups(
project_id: int,
Expand All @@ -43,10 +43,10 @@ def project_get_groups(


@project_router.post(
"/projects/{project_id}/groups",
dependencies=[Depends(ensure_teacher_authorized_for_project)],
"/projects/{project_id}/groups",
dependencies=[Depends(ensure_teacher_authorized_for_project)],
tags=[Tags.PROJECT],
summary="Create an empty group for a certain project."
summary="Create an empty group for a certain project.",
)
def project_create_group(
project_id: int,
Expand Down
6 changes: 5 additions & 1 deletion backend/routes/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def projects_of_student_get(
return get_projects_of_student(session, student.id)


@student_router.post("/student/subjects/{subject_id}/join", tags=[Tags.STUDENT], summary="Join a certain subject (for student).")
@student_router.post(
"/student/subjects/{subject_id}/join",
tags=[Tags.STUDENT],
summary="Join a certain subject (for student).",
)
def student_subject_join(
subject_id: int,
session: Session = Depends(get_session),
Expand Down
21 changes: 18 additions & 3 deletions backend/routes/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,32 @@
subject_router = APIRouter()


@subject_router.get("/subjects/{subject_id}", dependencies=[Depends(get_authenticated_user)], tags=[Tags.SUBJECT], summary="Get a certain subject.")
@subject_router.get(
"/subjects/{subject_id}",
dependencies=[Depends(get_authenticated_user)],
tags=[Tags.SUBJECT],
summary="Get a certain subject.",
)
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(ensure_user_authorized_for_subject)], tags=[Tags.SUBJECT], summary="Get all projects of a certain subject.")
@subject_router.get(
"/subjects/{subject_id}/projects",
dependencies=[Depends(ensure_user_authorized_for_subject)],
tags=[Tags.SUBJECT],
summary="Get all projects of a certain subject.",
)
def get_subject_projects(subject_id: int, session: Session = Depends(get_session)) -> list[ProjectDataclass]:
return get_projects_of_subject(session, subject_id)


@subject_router.post("/subjects/{subject_id}/projects", dependencies=[Depends(ensure_teacher_authorized_for_subject)], tags=[Tags.SUBJECT], summary="Create a new project linked to a certain subject.")
@subject_router.post(
"/subjects/{subject_id}/projects",
dependencies=[Depends(ensure_teacher_authorized_for_subject)],
tags=[Tags.SUBJECT],
summary="Create a new project linked to a certain subject.",
)
def new_project(
subject_id: int,
project: ProjectInput,
Expand Down
1 change: 1 addition & 0 deletions backend/routes/tags/swagger_tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from enum import Enum


class Tags(Enum):
GROUP = "Group methods"
LOGIN = "Login methods"
Expand Down
21 changes: 18 additions & 3 deletions backend/routes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,34 @@ def modify_current_user(
return Response(status_code=status.HTTP_204_NO_CONTENT)


@users_router.get("/users", dependencies=[Depends(get_authenticated_admin)], tags=[Tags.USER], summary="Get all users.")
@users_router.get(
"/users",
dependencies=[Depends(get_authenticated_admin)],
tags=[Tags.USER],
summary="Get all users.",
)
def get_users(session: Session = Depends(get_session)) -> list[APIUser]:
users: list[UserDataclass] = [user.to_domain_model() for user in get_all(session, User)]
return [convert_user(session, user) for user in users]


@users_router.get("/users/{uid}", dependencies=[Depends(get_authenticated_admin)], tags=[Tags.USER], summary="Get a certain user.")
@users_router.get(
"/users/{uid}",
dependencies=[Depends(get_authenticated_admin)],
tags=[Tags.USER],
summary="Get a certain user.",
)
def admin_get_user(uid: int, session: Session = Depends(get_session)) -> APIUser:
user: UserDataclass = get(session, User, uid).to_domain_model()
return convert_user(session, user)


@users_router.patch("/users/{uid}", dependencies=[Depends(get_authenticated_admin)], tags=[Tags.USER], summary="Modify the roles of a certain user.")
@users_router.patch(
"/users/{uid}",
dependencies=[Depends(get_authenticated_admin)],
tags=[Tags.USER],
summary="Modify the roles of a certain user.",
)
def modify_user(uid: int, roles: list[Role], session: Session = Depends(get_session)) -> Response:
modify_user_roles(session, uid, roles)
return Response(status_code=status.HTTP_204_NO_CONTENT)

0 comments on commit 5b32f0e

Please sign in to comment.