Skip to content

Commit

Permalink
fix authors cannot see hidden courses
Browse files Browse the repository at this point in the history
  • Loading branch information
bojieli committed Feb 28, 2024
1 parent 04d8864 commit eaeab35
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ def view_course(course_id):
'score': '评分: 低-高',
}

query = Review.query.filter_by(course_id=course.id).filter_by(is_hidden=False)
query = Review.query.filter_by(course_id=course.id)

# filter hidden reviews to get correct review count
if not current_user.is_authenticated:
query = query.filter_by(is_hidden=False)
elif not current_user.is_admin:
query = query.filter(or_(Review.is_hidden==False, Review.author_id==current_user.id))

# get terms list which have review
review_term_list = course.review_term_list
Expand Down

0 comments on commit eaeab35

Please sign in to comment.