Update scope query for new teacher definition

This commit is contained in:
Sebastian Serth
2022-09-20 11:31:25 +02:00
committed by Sebastian Serth
parent 964048927a
commit 02c65af034
4 changed files with 18 additions and 10 deletions

View File

@@ -21,7 +21,7 @@ class StudyGroupPolicy < AdminOnlyPolicy
if @user.admin?
@scope.all
elsif @user.teacher?
@scope.joins(:study_group_memberships).where('user_id = ? AND user_type = ?', @user.id, @user.class.name)
@scope.joins(:study_group_memberships).where(study_group_memberships: {user: @user, role: StudyGroupMembership.roles[:teacher]})
else
@scope.none
end