panda_pal 5.4.5 → 5.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6de9e366030521aaa18328dbb06bfdb1ebb40a27493fab4c0168f85195f3838e
4
- data.tar.gz: a08d0f4c61695f4898ec46d004e06e9115aee2759bef97499bd17501d18f14c2
3
+ metadata.gz: 54f85983099ebb935266fb0f7a5671dea933b70c02557af3af732dd63b81a603
4
+ data.tar.gz: 2566905d0ddd340582f5e2171278c5d2bcde892d374c024cb7deba29b06d711a
5
5
  SHA512:
6
- metadata.gz: bd659d9a64acbb986f7481faf8962dff90cdfc1c9c2654462fff6f293e9757c3d87edc55337cc56cf1ab6ab0208f0b8be186d6ba3f81e01aaaa0705cbd6137e1
7
- data.tar.gz: 0fc0ddb7daf4ec3636deedb6e47fa866b0511ca66d338d19c19817020f7ee8ab871c08b40ef37172678c52f14a0697f8fe41ef1374b6a1c9242b9f795dbeec55
6
+ metadata.gz: 9e52048202eda9ba571e496c909dc85cf961d89a45612d5fd5a80c085ee6fd4a83286058df4c0a953c3456ffea31927dfcfc14c77a628468492d6f0ca0bccb20
7
+ data.tar.gz: d893fc73823f914ae8590311333660a8100357db27fc2510c1663a36dc8bf905bff4fc0dae1db0091ad8ef9656dec24a46e16e8852d7788cf6cb3b26d27045e8
@@ -1,4 +1,12 @@
1
1
  module PandaPal
2
2
  class ApplicationController < ActionController::Base
3
+ around_action :share_controller_on_thread
4
+
5
+ def share_controller_on_thread
6
+ Thread.current[:controller] = self
7
+ yield
8
+ ensure
9
+ Thread.current[:controller] = nil
10
+ end
3
11
  end
4
12
  end
@@ -17,10 +17,24 @@ module PandaPal
17
17
  end
18
18
  end
19
19
 
20
+ def self.url_for(options)
21
+ request = Thread.current[:controller]&.request
22
+ host = "#{request.scheme}://#{request.host_with_port}"
23
+ if options.is_a?(Symbol)
24
+ Rails.application.routes.url_helpers.send(options, host: host)
25
+ else
26
+ options[:host] ||= host
27
+ Rails.application.routes.url_helpers.url_for(options)
28
+ end
29
+ end
30
+
20
31
  def self.normalize_lti_launch_desc(opts)
21
32
  opts = opts.dup
22
33
  opts.delete(:route_helper_key)
23
34
  opts.delete(:auto_launch)
35
+ opts.each do |k, v|
36
+ opts[k] = v.call if v.is_a?(Proc)
37
+ end
24
38
  opts
25
39
  end
26
40
 
@@ -18,6 +18,8 @@ class RemoveOldOrganizationSettings < PandaPal::MiscHelper::MigrationClass
18
18
  #PandaPal::Organization.connection.schema_cache.clear!
19
19
  #PandaPal::Organization.reset_column_information
20
20
  PandaPal::Organization.find_each do |o|
21
+ next unless o.old_settings.present?
22
+
21
23
  # Would like to just be able to do this:
22
24
  # o.settings = YAML.load(o.old_settings)
23
25
  # o.save!
@@ -61,7 +61,7 @@ module PandaPal::Helpers
61
61
  end
62
62
 
63
63
  def current_session_data
64
- current_session.data
64
+ current_session.data&.with_indifferent_access
65
65
  end
66
66
 
67
67
  def session_changed?
@@ -2,5 +2,4 @@ module PandaPal::Helpers
2
2
  require_relative 'helpers/controller_helper'
3
3
  require_relative 'helpers/route_helper'
4
4
  require_relative 'helpers/secure_headers'
5
- require_relative 'helpers/ability_mixin'
6
5
  end
@@ -1,3 +1,3 @@
1
1
  module PandaPal
2
- VERSION = "5.4.5"
2
+ VERSION = "5.4.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_pal
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.5
4
+ version: 5.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure ProServe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-07 00:00:00.000000000 Z
11
+ date: 2022-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -226,7 +226,6 @@ files:
226
226
  - lib/panda_pal.rb
227
227
  - lib/panda_pal/engine.rb
228
228
  - lib/panda_pal/helpers.rb
229
- - lib/panda_pal/helpers/ability_mixin.rb
230
229
  - lib/panda_pal/helpers/controller_helper.rb
231
230
  - lib/panda_pal/helpers/route_helper.rb
232
231
  - lib/panda_pal/helpers/secure_headers.rb
@@ -1,85 +0,0 @@
1
- module PandaPal
2
- module AbilityMixin
3
- extend ActiveSupport::Concern
4
-
5
- class_methods do
6
- def self.role_permissions(labels)
7
- roles = find_roles_by_label(labels)
8
-
9
- if Rails.env.test? && roles.count == 0 && (labels || []).include?('Administrator')
10
- return Hash.new(true)
11
- end
12
-
13
- final = {}
14
- roles.find_each do |role|
15
- role.permissions.each do |perm_name, perm|
16
- final[perm_name] = false if final[perm_name].nil?
17
- final[perm_name] = true if perm['enabled'] == true
18
- end
19
- end
20
- final
21
- end
22
-
23
- def self.find_roles_by_label(labels)
24
- raise "PandaPal AbilityMixin's support for Roles and Permissions requires that Roles be synced by CanvasSync" unless defined?(Role)
25
-
26
- built_ins = []
27
- labels = labels.split(',') if labels.is_a?(String)
28
- custom_labels = Array(labels).reject do |l|
29
- if role_is_default?(l)
30
- built_ins << l
31
- elsif l == 'Account Admin'
32
- built_ins << 'AccountMembership'
33
- else
34
- next
35
- end
36
- true
37
- end
38
- Role.where(workflow_state: 'built_in', base_role_type: built_ins)
39
- .or(Role.where.not(workflow_state: 'built_in').where(label: custom_labels))
40
- end
41
-
42
- def self.role_is_default?(role)
43
- %w[TeacherEnrollment TaEnrollment StudentEnrollment DesignerEnrollment ObserverEnrollment].include? role
44
- end
45
- end
46
-
47
- def is_lti_launch?
48
- @controller.current_session.present?
49
- end
50
-
51
- def panda_pal_session
52
- @panda_pal_session ||= @controller.current_session&.data || {}
53
- end
54
-
55
- def rails_session
56
- @rails_session ||= @controller.session
57
- end
58
-
59
- def launch_params
60
- @launch_params ||= panda_pal_session[:launch_params] || {}
61
- end
62
-
63
- # Roles and Permissions
64
- def lti_roles
65
- @lti_roles ||= LTIRoles::RoleManager.new(launch_params['ext_roles'] || '')
66
- end
67
-
68
- def canvas_permissions
69
- panda_pal_session[:canvas_permissions] ||= self.class.role_permissions(launch_params['custom_canvas_role'])
70
- end
71
-
72
- def canvas_role_labels
73
- labels = launch_params['custom_canvas_role']
74
- labels.is_a?(String) ? labels.split(',') : []
75
- end
76
-
77
- def canvas_roles
78
- self.class.find_roles_by_label(canvas_role_labels)
79
- end
80
-
81
- def launch_role_ids
82
- panda_pal_session[:launch_role_ids] ||= canvas_roles.map(&:canvas_id)
83
- end
84
- end
85
- end