Skip to content

Commit

Permalink
fix 2
Browse files Browse the repository at this point in the history
  • Loading branch information
zipperman1 committed Nov 24, 2024
1 parent 59c484f commit 91a022d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions rating_api/routes/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depen
Для возможности создания комментария с указанием времени создания и изменения необходим скоуп ["rating.comment.import"]
"""
lecturer = Lecturer.get(session=db.session, id=lecturer_id)
if not lecturer:
raise ObjectNotFound(Lecturer, lecturer_id)

has_create_scope = "rating.comment.import" in [scope['name'] for scope in user.get('session_scopes')]
if (comment_info.create_ts or comment_info.update_ts) and not has_create_scope:
raise ForbiddenAction(Comment)

lecturer = Lecturer.get(session=db.session, id=lecturer_id)
if not lecturer:
raise ObjectNotFound(Lecturer, lecturer_id)

if not has_create_scope:
user_comments: list[LecturerUserComment] = (
LecturerUserComment.query(session=db.session).filter(LecturerUserComment.user_id == user.get("id")).all()
Expand Down

0 comments on commit 91a022d

Please sign in to comment.