Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
c011c67dcf
commit
fec37cc171
50
endpoints/api/v1/endpoint.post.py
Normal file
50
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
from core.database import fake_users_db
|
||||||
|
import uuid
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/courses")
|
||||||
|
async def create_course(
|
||||||
|
title: str,
|
||||||
|
description: str,
|
||||||
|
instructor_id: str,
|
||||||
|
price: float,
|
||||||
|
duration_weeks: int,
|
||||||
|
max_students: Optional[int] = None
|
||||||
|
):
|
||||||
|
"""Create a new course in the online school"""
|
||||||
|
course_id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
if not fake_users_db.get(instructor_id):
|
||||||
|
raise HTTPException(status_code=400, detail="Instructor not found")
|
||||||
|
|
||||||
|
course = {
|
||||||
|
"id": course_id,
|
||||||
|
"title": title,
|
||||||
|
"description": description,
|
||||||
|
"instructor_id": instructor_id,
|
||||||
|
"price": price,
|
||||||
|
"duration_weeks": duration_weeks,
|
||||||
|
"max_students": max_students,
|
||||||
|
"enrolled_students": [],
|
||||||
|
"status": "active"
|
||||||
|
}
|
||||||
|
|
||||||
|
fake_users_db[course_id] = course
|
||||||
|
|
||||||
|
return {
|
||||||
|
"message": "Course created successfully",
|
||||||
|
"course_id": course_id,
|
||||||
|
"course_details": course,
|
||||||
|
"features": {
|
||||||
|
"enrollment_open": True,
|
||||||
|
"materials_ready": False
|
||||||
|
},
|
||||||
|
"next_steps": [
|
||||||
|
"Upload course materials",
|
||||||
|
"Set up course schedule",
|
||||||
|
"Invite students"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user