Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
zipperman1 committed Nov 17, 2024
1 parent e0786db commit 987636e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rating_api/routes/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depen
raise ObjectNotFound(Lecturer, lecturer_id)

current_time = datetime.datetime.utcnow()
has_review_scope = "rating.comment.review" in [scope['name'] for scope in user.get('session_scopes')]
if comment_info.create_ts or comment_info.update_ts:
if "rating.comment.review" not in [scope['name'] for scope in user.get('session_scopes')]:
if not has_review_scope:
raise ForbiddenAction(Comment)
else:
if not comment_info.create_ts:
Expand All @@ -47,7 +48,7 @@ async def create_comment(lecturer_id: int, comment_info: CommentPost, user=Depen
LecturerUserComment.query(session=db.session).filter(LecturerUserComment.user_id == user.get("id")).all()
)

if "rating.comment.review" not in [scope['name'] for scope in user.get('session_scopes')]:
if not has_review_scope:
for user_comment in user_comments:
if current_time - user_comment.update_ts < datetime.timedelta(
minutes=settings.COMMENT_CREATE_FREQUENCY_IN_MINUTES
Expand Down

0 comments on commit 987636e

Please sign in to comment.