panda_pal 5.4.1 → 5.4.5

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: 682c93cece4f79d9c12499c2ef13e31ac9492d1f96640717915c07f1944318de
4
- data.tar.gz: 782c6bac9411aaa23d0a6d34ac0914e5a241b8b872582acff995bec51f8abfb9
3
+ metadata.gz: 6de9e366030521aaa18328dbb06bfdb1ebb40a27493fab4c0168f85195f3838e
4
+ data.tar.gz: a08d0f4c61695f4898ec46d004e06e9115aee2759bef97499bd17501d18f14c2
5
5
  SHA512:
6
- metadata.gz: '0454692740709dc1be385443d5928631b87a9420a5a7666d7ef97ce18c55ff3776e3c3062ba1dfa2a236b69346b41c6139fa066a852faeb2aa667d0181c37317'
7
- data.tar.gz: 699eff3766812c8bd3482df79e44a9f198865b2f556a92164496c22bfbfb4fb6e331c061e62467098e1c5ea7a495c591e54c37512944048e9226b3b9af30d083
6
+ metadata.gz: bd659d9a64acbb986f7481faf8962dff90cdfc1c9c2654462fff6f293e9757c3d87edc55337cc56cf1ab6ab0208f0b8be186d6ba3f81e01aaaa0705cbd6137e1
7
+ data.tar.gz: 0fc0ddb7daf4ec3636deedb6e47fa866b0511ca66d338d19c19817020f7ee8ab871c08b40ef37172678c52f14a0697f8fe41ef1374b6a1c9242b9f795dbeec55
@@ -49,6 +49,10 @@ module PandaPal
49
49
  end
50
50
  end
51
51
 
52
+ def self.current
53
+ find_by_name(Apartment::Tenant.current)
54
+ end
55
+
52
56
  PandaPal.resolved_extensions_for(self).each do |ext|
53
57
  include ext
54
58
  end
@@ -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
@@ -160,7 +161,7 @@ module PandaPal
160
161
  private
161
162
 
162
163
  def unschedule_tasks(new_task_keys = nil)
163
- current_schedules = Sidekiq.get_schedule.select { |k,v| k.starts_with?("org:#{name}-") }
164
+ current_schedules = Sidekiq.get_schedule.select { |k,v| k.start_with?("org:#{name}-") }
164
165
  del_tasks = current_schedules.keys
165
166
  del_tasks -= new_task_keys if new_task_keys
166
167
  del_tasks.each do |k|
@@ -198,13 +199,19 @@ module PandaPal
198
199
 
199
200
  Apartment::Tenant.switch(org.name) do
200
201
  if worker.is_a?(Proc)
201
- org.instance_exec(&worker)
202
+ return org.instance_exec(&worker)
202
203
  elsif worker.is_a?(Symbol)
203
- org.send(worker)
204
+ return org.send(worker)
204
205
  elsif worker.is_a?(String)
205
- worker.constantize.perform_async
206
- elsif worker.is_a?(Class)
207
- worker.perform_async
206
+ worker = worker.constantize
207
+ end
208
+
209
+ if worker.is_a?(Class)
210
+ if worker.respond_to?(:perform_async)
211
+ worker.perform_async
212
+ else
213
+ worker.perform_later
214
+ end
208
215
  end
209
216
  end
210
217
  end
@@ -12,7 +12,7 @@ end
12
12
  Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request|
13
13
  if match = request.path.match(/\/(?:orgs?|organizations?)\/(\d+)/)
14
14
  PandaPal::Organization.find_by(id: match[1]).try(:name)
15
- elsif request.path.starts_with?('/rails/active_storage/blobs/')
15
+ elsif request.path.start_with?('/rails/active_storage/blobs/')
16
16
  PandaPal::Organization.find_by(id: request.params['organization_id']).try(:name)
17
17
  end
18
18
  }
@@ -0,0 +1,85 @@
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
@@ -2,4 +2,5 @@ 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'
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module PandaPal
2
- VERSION = "5.4.1"
2
+ VERSION = "5.4.5"
3
3
  end
data/lib/panda_pal.rb CHANGED
@@ -91,7 +91,7 @@ module PandaPal
91
91
 
92
92
  def self.normalize_ext_type(type)
93
93
  type = type.to_s
94
- type = "#{self.to_s}::#{type}" unless type.starts_with?('::') || type.starts_with?(self.to_s)
94
+ type = "#{self.to_s}::#{type}" unless type.start_with?('::') || type.start_with?(self.to_s)
95
95
  type
96
96
  end
97
97
 
data/panda_pal.gemspec CHANGED
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_dependency "rails", ">= 4.2"
19
19
  s.add_dependency 'ros-apartment', '~> 2.2'
20
- s.add_dependency 'pg', '>= 0.20', '< 1.0.0'
21
20
  s.add_dependency 'ims-lti', '~> 1.2.4'
22
21
  s.add_dependency 'browser', '2.5.0'
23
22
  s.add_dependency 'attr_encrypted', '~> 3.0.0'
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.1
4
+ version: 5.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure ProServe
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-23 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,26 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.2'
41
- - !ruby/object:Gem::Dependency
42
- name: pg
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0.20'
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: 1.0.0
51
- type: :runtime
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: '0.20'
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: 1.0.0
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: ims-lti
63
43
  requirement: !ruby/object:Gem::Requirement
@@ -198,7 +178,7 @@ dependencies:
198
178
  - - ">="
199
179
  - !ruby/object:Gem::Version
200
180
  version: '0'
201
- description:
181
+ description:
202
182
  email:
203
183
  - pseng@instructure.com
204
184
  executables: []
@@ -246,6 +226,7 @@ files:
246
226
  - lib/panda_pal.rb
247
227
  - lib/panda_pal/engine.rb
248
228
  - lib/panda_pal/helpers.rb
229
+ - lib/panda_pal/helpers/ability_mixin.rb
249
230
  - lib/panda_pal/helpers/controller_helper.rb
250
231
  - lib/panda_pal/helpers/route_helper.rb
251
232
  - lib/panda_pal/helpers/secure_headers.rb
@@ -300,7 +281,7 @@ homepage: http://instructure.com
300
281
  licenses:
301
282
  - MIT
302
283
  metadata: {}
303
- post_install_message:
284
+ post_install_message:
304
285
  rdoc_options: []
305
286
  require_paths:
306
287
  - lib
@@ -315,50 +296,50 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
296
  - !ruby/object:Gem::Version
316
297
  version: '0'
317
298
  requirements: []
318
- rubygems_version: 3.2.15
319
- signing_key:
299
+ rubygems_version: 3.0.3
300
+ signing_key:
320
301
  specification_version: 4
321
302
  summary: LTI mountable engine
322
303
  test_files:
323
- - spec/dummy/README.rdoc
304
+ - spec/rails_helper.rb
305
+ - spec/models/panda_pal/organization_spec.rb
306
+ - spec/models/panda_pal/session_spec.rb
307
+ - spec/models/panda_pal/organization/settings_validation_spec.rb
308
+ - spec/models/panda_pal/organization/task_scheduling_spec.rb
309
+ - spec/spec_helper.rb
310
+ - spec/dummy/db/schema.rb
311
+ - spec/dummy/public/422.html
312
+ - spec/dummy/public/favicon.ico
313
+ - spec/dummy/public/404.html
314
+ - spec/dummy/public/500.html
324
315
  - spec/dummy/Rakefile
325
- - spec/dummy/app/assets/javascripts/application.js
326
- - spec/dummy/app/assets/stylesheets/application.css
316
+ - spec/dummy/app/views/layouts/application.html.erb
327
317
  - spec/dummy/app/controllers/application_controller.rb
328
318
  - spec/dummy/app/helpers/application_helper.rb
329
- - spec/dummy/app/views/layouts/application.html.erb
330
- - spec/dummy/bin/bundle
331
- - spec/dummy/bin/rails
332
- - spec/dummy/bin/rake
333
- - spec/dummy/bin/setup
319
+ - spec/dummy/app/assets/stylesheets/application.css
320
+ - spec/dummy/app/assets/javascripts/application.js
321
+ - spec/dummy/config/secrets.yml
334
322
  - spec/dummy/config/application.rb
335
- - spec/dummy/config/boot.rb
336
- - spec/dummy/config/database.yml
337
- - spec/dummy/config/environment.rb
338
- - spec/dummy/config/environments/development.rb
339
- - spec/dummy/config/environments/production.rb
340
- - spec/dummy/config/environments/test.rb
341
- - spec/dummy/config/initializers/backtrace_silencers.rb
342
- - spec/dummy/config/initializers/cookies_serializer.rb
343
- - spec/dummy/config/initializers/filter_parameter_logging.rb
344
- - spec/dummy/config/initializers/inflections.rb
345
- - spec/dummy/config/initializers/mime_types.rb
346
323
  - spec/dummy/config/initializers/session_store.rb
347
324
  - spec/dummy/config/initializers/wrap_parameters.rb
348
- - spec/dummy/config/locales/en.yml
325
+ - spec/dummy/config/initializers/inflections.rb
326
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
327
+ - spec/dummy/config/initializers/mime_types.rb
328
+ - spec/dummy/config/initializers/backtrace_silencers.rb
329
+ - spec/dummy/config/initializers/cookies_serializer.rb
330
+ - spec/dummy/config/environments/development.rb
331
+ - spec/dummy/config/environments/test.rb
332
+ - spec/dummy/config/environments/production.rb
333
+ - spec/dummy/config/database.yml
334
+ - spec/dummy/config/boot.rb
349
335
  - spec/dummy/config/routes.rb
350
- - spec/dummy/config/secrets.yml
336
+ - spec/dummy/config/environment.rb
337
+ - spec/dummy/config/locales/en.yml
338
+ - spec/dummy/README.rdoc
351
339
  - spec/dummy/config.ru
352
- - spec/dummy/db/schema.rb
353
- - spec/dummy/public/404.html
354
- - spec/dummy/public/422.html
355
- - spec/dummy/public/500.html
356
- - spec/dummy/public/favicon.ico
340
+ - spec/dummy/bin/bundle
341
+ - spec/dummy/bin/rake
342
+ - spec/dummy/bin/setup
343
+ - spec/dummy/bin/rails
357
344
  - spec/factories/panda_pal_organizations.rb
358
345
  - spec/factories/panda_pal_sessions.rb
359
- - spec/models/panda_pal/organization/settings_validation_spec.rb
360
- - spec/models/panda_pal/organization/task_scheduling_spec.rb
361
- - spec/models/panda_pal/organization_spec.rb
362
- - spec/models/panda_pal/session_spec.rb
363
- - spec/rails_helper.rb
364
- - spec/spec_helper.rb