Skip to content

Commit

Permalink
students, crud_course: fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
DenitsaTH committed Jun 10, 2024
1 parent da8ff25 commit b2e934e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/app/api/api_v1/routes/students.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def update_profile_picture(db: dbDep, student: StudentAuthDep, file: Uploa
status_code=status.HTTP_400_BAD_REQUEST, detail='File is corrupted or media type is not supported')


@router.get('/', response_model=StudentResponseModel)
@router.get('/', response_model=StudentResponseModel | None)
async def view_account(db: dbDep, student: StudentAuthDep) -> StudentResponseModel:
"""
Shows authenticated student's profile information.
Expand All @@ -78,7 +78,7 @@ async def view_account(db: dbDep, student: StudentAuthDep) -> StudentResponseMod
return await crud_student.get_student(db=db, email=student.account.email)


@router.put('/', status_code=status.HTTP_201_CREATED, response_model=StudentResponseModel)
@router.put('/', status_code=status.HTTP_201_CREATED, response_model=StudentResponseModel | None)
async def edit_account(db: dbDep, student: StudentAuthDep, updates: StudentEdit) -> StudentResponseModel:
"""
Edits authenticated student's profile information.
Expand Down Expand Up @@ -151,7 +151,7 @@ async def view_pending_courses(db: dbDep, student: StudentAuthDep) -> list[Cours
return await crud_student.view_pending_requests(db, student)


@router.get('/courses/{course_id}', response_model=StudentCourseSchema)
@router.get('/courses/{course_id}', response_model=StudentCourseSchema | None)
async def view_course(db: dbDep, student: StudentAuthDep, course_id: int) -> StudentCourseSchema:
"""
Returns authenticated student's chosen course with details.
Expand Down
2 changes: 1 addition & 1 deletion src/app/crud/crud_course.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


async def get_course_by_id(db: Session, course_id: int, auto_error=False) -> Course | None:
query = db.query(Course).filter(Course.course_id == course_id).first()
query = db.query(Course).filter(Course.course_id == course_id, Course.is_hidden == False).first()

if query:
return query
Expand Down

0 comments on commit b2e934e

Please sign in to comment.