Finish most work on course progress endpoints
This commit is contained in:
25
src/main.py
25
src/main.py
@@ -1,6 +1,5 @@
|
||||
from typing import List, Optional
|
||||
|
||||
import jwt
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@@ -70,16 +69,6 @@ async def create_high_score(
|
||||
return crud_highscores.create_high_score(db, current_user, high_score)
|
||||
|
||||
|
||||
#### TESTING!! DELETE LATER
|
||||
|
||||
|
||||
@app.get("/protected")
|
||||
async def protected_route(
|
||||
current_user_name: str = Depends(crud_authentication.get_current_user_name),
|
||||
):
|
||||
return {"message": f"Hello, {current_user_name}!"}
|
||||
|
||||
|
||||
@app.get("/courseprogress", response_model=List[courseprogress.CourseProgressBase])
|
||||
async def get_course_progress(
|
||||
course: Optional[CourseEnum] = CourseEnum.All,
|
||||
@@ -92,9 +81,19 @@ async def get_course_progress(
|
||||
|
||||
@app.patch("/courseprogress")
|
||||
async def get_course_progress(
|
||||
course_progress: courseprogress.CourseProgressBase,
|
||||
current_user_name: str = Depends(crud_authentication.get_current_user_name),
|
||||
course: Optional[CourseEnum] = CourseEnum.All,
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
current_user = crud_users.get_user_by_username(db, current_user_name)
|
||||
return crud_courseprogress.get_course_progress(db, current_user, course)
|
||||
return crud_courseprogress.patch_course_progress(db, current_user, course_progress)
|
||||
|
||||
|
||||
#### TESTING!! DELETE LATER
|
||||
|
||||
|
||||
@app.get("/protected")
|
||||
async def protected_route(
|
||||
current_user_name: str = Depends(crud_authentication.get_current_user_name),
|
||||
):
|
||||
return {"message": f"Hello, {current_user_name}!"}
|
||||
|
||||
Reference in New Issue
Block a user