Skip to content

Commit b348636

Browse files
committed
Fix submission access for teacher_in_study_group?
1 parent e322d74 commit b348636

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

app/policies/submission_policy.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ def index?
2323
end
2424

2525
def show?
26-
admin? || author? || author_in_programming_group? || teacher_in_study_group?
27-
end
28-
29-
def show_study_group?
30-
admin? || teacher_in_study_group?
26+
admin? || author? || author_in_programming_group? || (teacher_in_study_group? && CausesScope.new(@user, @record).resolve.include?(@record.cause))
3127
end
3228

3329
class Scope < Scope

app/views/external_users/statistics.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ h1 = t('.title', user: @user.displayname)
1717
- exercises.each do |exercise|
1818
// Grab any submission in context of study group (or all if admin). Then check for permission
1919
- any_submission = submissions.where(exercise:).first
20-
- if any_submission && policy(any_submission).show_study_group? && statistics[exercise.id]
20+
- if any_submission && policy(any_submission.study_group).show? && statistics[exercise.id]
2121
- stats = statistics[exercise.id]
2222
tr
2323
td = link_to exercise, controller: 'exercises', action: 'external_user_statistics', external_user_id: @user.id, id: exercise.id

app/views/request_for_comments/show.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
- testruns = submission.testruns
1212
= link_to_if(policy(user).show?, user.displayname, user)
1313
| | #{@request_for_comment.created_at.localtime}
14-
- if @request_for_comment.submission.study_group.present? && policy(@request_for_comment.submission).show_study_group?
14+
- if @request_for_comment.submission.study_group.present? && policy(@request_for_comment.submission.study_group).show?
1515
= ' | '
1616
= link_to_if(policy(@request_for_comment.submission.study_group).show?, @request_for_comment.submission.study_group, @request_for_comment.submission.study_group)
1717
.rfc

0 commit comments

Comments
 (0)