From b1170da6978a2983a1a53c067a7c8746ab1ea78e Mon Sep 17 00:00:00 2001 From: swve Date: Tue, 20 Sep 2022 23:57:19 +0200 Subject: [PATCH] chore: cleanup --- src/main.py | 1 - src/services/courses.py | 36 +++++++++++++++++------------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/main.py b/src/main.py index e1bec4b5..a2f145b3 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,5 @@ from fastapi import APIRouter from src.routers import collections, courses, users, auth, houses, orgs, roles -from starlette.responses import FileResponse global_router = APIRouter(prefix="/api") diff --git a/src/services/courses.py b/src/services/courses.py index efc12b16..a4fce7b7 100644 --- a/src/services/courses.py +++ b/src/services/courses.py @@ -164,25 +164,6 @@ async def get_courses(page: int = 1, limit: int = 10): # CoursesChapters - -async def get_coursechapter(coursechapter_id: str, current_user: User): - await check_database() - coursechapters = learnhouseDB["coursechapters"] - - coursechapter = coursechapters.find_one( - {"coursechapter_id": coursechapter_id}) - - # verify course rights - await verify_rights(coursechapter["course_id"], current_user, "read") - - if not coursechapter: - raise HTTPException( - status_code=status.HTTP_409_CONFLICT, detail="CourseChapter does not exist") - - coursechapter = CourseChapter(**coursechapter) - return coursechapter - - async def create_coursechapter(coursechapter_object: CourseChapter, course_id: str, current_user: User): await check_database() coursechapters = learnhouseDB["coursechapters"] @@ -208,6 +189,23 @@ async def create_coursechapter(coursechapter_object: CourseChapter, course_id: s return coursechapter.dict() +async def get_coursechapter(coursechapter_id: str, current_user: User): + await check_database() + coursechapters = learnhouseDB["coursechapters"] + + coursechapter = coursechapters.find_one( + {"coursechapter_id": coursechapter_id}) + + # verify course rights + await verify_rights(coursechapter["course_id"], current_user, "read") + + if not coursechapter: + raise HTTPException( + status_code=status.HTTP_409_CONFLICT, detail="CourseChapter does not exist") + + coursechapter = CourseChapter(**coursechapter) + return coursechapter + async def update_coursechapter(coursechapter_object: CourseChapter, coursechapter_id: str, current_user: User): await check_database() coursechapters = learnhouseDB["coursechapters"]