Skip to content

Commit

Permalink
Only return admistarting courses
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Nov 9, 2023
1 parent 1184a31 commit 00f760d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/lti_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def do_redirect

def content_selection
@supported = @lti_message.accept_types.include?(LTI::Messages::Types::DeepLinkingResponse::LtiResourceLink::TYPE)
@grouped_courses = policy_scope(Course.all).group_by(&:year)
@grouped_courses = current_user.administrating_courses.group_by(&:year)

Check warning on line 40 in app/controllers/lti_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/lti_controller.rb#L40

Added line #L40 was not covered by tests
@multiple = @lti_message.accept_multiple
end

Expand Down
23 changes: 23 additions & 0 deletions app/policies/lti_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class LabelPolicy < ApplicationPolicy
class Scope < Scope
def resolve
scope
end
end

Check warning on line 6 in app/policies/lti_policy.rb

View check run for this annotation

Codecov / codecov/patch

app/policies/lti_policy.rb#L1-L6

Added lines #L1 - L6 were not covered by tests

def content_selection?
current_user&.a_course_admin?
end

Check warning on line 10 in app/policies/lti_policy.rb

View check run for this annotation

Codecov / codecov/patch

app/policies/lti_policy.rb#L8-L10

Added lines #L8 - L10 were not covered by tests

def redirect?
true
end

Check warning on line 14 in app/policies/lti_policy.rb

View check run for this annotation

Codecov / codecov/patch

app/policies/lti_policy.rb#L12-L14

Added lines #L12 - L14 were not covered by tests

def do_redirect?
true
end

Check warning on line 18 in app/policies/lti_policy.rb

View check run for this annotation

Codecov / codecov/patch

app/policies/lti_policy.rb#L16-L18

Added lines #L16 - L18 were not covered by tests

def series_and_activities?
Course.find_by(id: params[:id]).each { |c| current_user&.admin_of?(c) }
end
end

Check warning on line 23 in app/policies/lti_policy.rb

View check run for this annotation

Codecov / codecov/patch

app/policies/lti_policy.rb#L20-L23

Added lines #L20 - L23 were not covered by tests

0 comments on commit 00f760d

Please sign in to comment.