Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions rating_api/routes/lecturer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
LecturerPatch,
LecturerPost,
LecturersFilter,
LecturerUpdateRatingPatch,
LecturerWithRank,
)
from rating_api.utils.mark import calc_weighted_mark
Expand Down Expand Up @@ -46,12 +47,14 @@ async def create_lecturer(
raise AlreadyExists(Lecturer, lecturer_info.timetable_id)


@lecturer.patch("/import_rating", response_model=dict)
@lecturer.patch("/import_rating", response_model=LecturerUpdateRatingPatch)
async def update_lecturer_rating(
lecturer_rank_info: list[LecturerWithRank],
_=Depends(UnionAuth(scopes=["rating.lecturer.update_rating"], allow_none=False, auto_error=True)),
) -> dict:
) -> LecturerUpdateRatingPatch:
"""
Scopes: `["rating.lecturer.impor_rating"]`

Обновляет рейтинг преподавателя в базе данных RatingAPI
"""
updated_lecturers = []
Expand Down Expand Up @@ -84,8 +87,9 @@ async def update_lecturer_rating(
else:
response["failed"] += 1
response["failed_id"].append(lecturer_id)
response_validated = LecturerUpdateRatingPatch.model_validate(**response)

return response
return response_validated


@lecturer.get("/{id}", response_model=LecturerGet)
Expand Down
7 changes: 7 additions & 0 deletions rating_api/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,10 @@ def sort(self, query: Query) -> Query:

class Constants(Filter.Constants):
model = Lecturer


class LecturerUpdateRatingPatch(Base):
updated: int
failed: int
updated_id: list[int]
failed_id: list[int]