mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-18 11:59:26 +00:00
chore: cleanup
This commit is contained in:
parent
0288e6d88e
commit
b1170da697
2 changed files with 17 additions and 20 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue