Always create a default study group for new consumers

This commit is contained in:
Sebastian Serth
2022-09-20 16:21:49 +02:00
committed by Sebastian Serth
parent 521626275f
commit cb1b163b30
3 changed files with 20 additions and 1 deletions

View File

@ -5,10 +5,17 @@ class StudyGroupPolicy < AdminOnlyPolicy
admin? || teacher?
end
%i[show? destroy? edit? update? stream_la?].each do |action|
%i[show? edit? update? stream_la?].each do |action|
define_method(action) { admin? || (@user.teacher? && @record.present? && @user.study_groups.exists?(@record.id)) }
end
def destroy?
# A default study group should not get deleted without the consumer
return no_one if @record.external_id.blank?
admin? || teacher_in_study_group?
end
class Scope < Scope
def resolve
if @user.admin?