panda_pal 5.4.4 → 5.4.7

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: 3ec5567515a06e761a0cb06597380d4a10a9454f58f903466f5871757323dc7c
4
- data.tar.gz: 418a9fe6dc99d53b6775b65c425db8c8c02aadf0adb2d92673934094bc26f3d7
3
+ metadata.gz: 2f1be48801ad434039bdca5a2a0a9f5c46ecb367487c773c66bc302cf1d218f7
4
+ data.tar.gz: fdc202caaf5132714191559b206809b553f49daf801f6c3e7f7dcba35bfa57e0
5
5
  SHA512:
6
- metadata.gz: 067dbe50e329437ada560115134fe992b3522e4bf971e73c9a22a375dd3803e5aa4897b1cf4af66fc1e31d8f905233d601a910cadaca740cd0a21a8c5d495831
7
- data.tar.gz: 1d5ffae5cd2f7a884799a23ae73e5d3935d2f64ff1397dc506a364c34de916e317f1098de64549f5e1c15fd033090a31646f171e3b779dcb45006a7251741460
6
+ metadata.gz: 10e708bb0f43c4ab219b0577237e221336ca5ca4759829757c009ea81e6e35528988e84f51d1bdaea2cae4a73d1d865fd896347171c7d27b1f6b9d9d4a9ece0c
7
+ data.tar.gz: f78cc8ee0232484e4133a9b3300c44748a310573be24b74813c2c57f35fbc1d174631e6d587a5be0c12fe5b9f1ea9ff5b51cbed463e83a0f6ddf0a8231484508
@@ -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
 
@@ -99,6 +99,7 @@ module PandaPal
99
99
  'queue' => desc[:queue],
100
100
  'class' => ScheduledTaskExecutor.to_s,
101
101
  'args' => [name, desc[:key]],
102
+ 'enabled' => !Rails.env.development?,
102
103
  }
103
104
  end
104
105
  schedule
@@ -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!
@@ -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.4"
2
+ VERSION = "5.4.7"
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.4
4
+ version: 5.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure ProServe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-20 00:00:00.000000000 Z
11
+ date: 2022-04-26 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