Use author_in_programming_group? policy for files & RfCs
* Allow all members of a programming group to list and solve RfCs * Also adjust policy specs to respect programming groups
This commit is contained in:

committed by
Sebastian Serth

parent
9d1be1eeff
commit
01accdae58
@ -50,9 +50,21 @@ class ApplicationPolicy
|
||||
private :teacher_in_study_group?
|
||||
|
||||
def author_in_programming_group?
|
||||
return false unless @record.contributor.programming_group?
|
||||
if @record.respond_to? :contributor # e.g. submission
|
||||
possible_programming_group = @record.contributor
|
||||
|
||||
@record.contributor.users.include?(@user)
|
||||
elsif @record.respond_to? :context # e.g. file
|
||||
possible_programming_group = @record.context.contributor
|
||||
|
||||
elsif @record.respond_to? :submission # e.g. request_for_comment
|
||||
possible_programming_group = @record.submission.contributor
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
return false unless possible_programming_group.programming_group?
|
||||
|
||||
possible_programming_group.users.include?(@user)
|
||||
end
|
||||
private :author_in_programming_group?
|
||||
|
||||
|
@ -38,7 +38,7 @@ module CodeOcean
|
||||
if @record.context.is_a?(Exercise)
|
||||
admin? || author?
|
||||
elsif @record.context.is_a?(Submission) && @record.context.exercise.allow_file_creation
|
||||
author?
|
||||
author? || author_in_programming_group?
|
||||
else
|
||||
no_one
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ class RequestForCommentPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def show?
|
||||
admin? || author? || rfc_visibility
|
||||
admin? || author? || author_in_programming_group? || rfc_visibility
|
||||
end
|
||||
|
||||
def destroy?
|
||||
@ -14,11 +14,11 @@ class RequestForCommentPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def mark_as_solved?
|
||||
admin? || author?
|
||||
admin? || author? || author_in_programming_group?
|
||||
end
|
||||
|
||||
def set_thank_you_note?
|
||||
admin? || author?
|
||||
admin? || author? || author_in_programming_group?
|
||||
end
|
||||
|
||||
def clear_question?
|
||||
|
Reference in New Issue
Block a user