mumukit-platform 4.2.0 → 6.0.0

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: a9debde5cab571898e9f88dd89a6f6800dfc9a1549ae00fc5d84792aa15cdc17
4
- data.tar.gz: 6eae2161b167142e81ea81920316d3ec68e394545c0b0952fd8c5ec5606f22b1
3
+ metadata.gz: 6ae45d9ce60a16c9d6b9cf2dc0284d02bd81832a40c0ed1a158495c4c00b849b
4
+ data.tar.gz: 603939ae2583641c628a0800a242bb33b9e6b21c5b4cf9ce6457b8e9eb1c5af1
5
5
  SHA512:
6
- metadata.gz: ff19191a1dbca41064ecf36df3e0e945546ad30a179a53bd3f763552c86cb65e9ccb8819f755c7b1fff5bedc0571c7ef25bb8eb2eecb5f734c47184567e926d4
7
- data.tar.gz: a76f6ca3e5b593d77f748e9205503d2986808eade31f2207e7e30ffdf880b027237e69d18245d1b5e2f8972fb8d2884cf1e31cbf8160f4561a6c2f2aaadb86ea
6
+ metadata.gz: 13726c3f29e85f3ab7ad93dec1d16845e1e51260c0412863d4be209058d9eeab79ee88bf696edc6237e584a46595ac102073244bea93f59d6f71884db630421f
7
+ data.tar.gz: f8ba4d912df7db4f502a5193f547b0e96be9222ac81801eb6e03e20a370d3c177adb208fcc8df0063445a570ddc21ab141a0bc53430e7e26638cce524135161a
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.6.3
@@ -1,8 +1,8 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.14.2
4
+ - 2.6.3
5
+ before_install: gem install bundler -v 2.0.2
6
6
  deploy:
7
7
  provider: rubygems
8
8
  api_key:
data/README.md CHANGED
@@ -23,6 +23,22 @@ Or install it yourself as:
23
23
 
24
24
  $ gem install mumukit-platform
25
25
 
26
+ ## Requeriments
27
+
28
+ In order to properly use this gem, you must declare _organization_, _course_ and _user_ classes, and implement some required methods:
29
+
30
+ _organization_:
31
+ * `#name`
32
+ * `#locale`
33
+ * `.find_by_name!`
34
+
35
+ _user_:
36
+ * `.find_by_uid!`
37
+
38
+ _course_:
39
+ * `.find_by_slug!`
40
+
41
+
26
42
  ## Contributing
27
43
 
28
44
  Bug reports and pull requests are welcome on GitHub at https://github.com/mumuki/mumukit-platform. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -30,4 +46,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/mumuki
30
46
  ## License
31
47
 
32
48
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
33
-
@@ -26,6 +26,19 @@ module Mumukit::Platform
26
26
  end
27
27
 
28
28
  CORE_MODELS.each do |klass|
29
+ # Configured classes must implement the following methods:
30
+ #
31
+ # _organization_:
32
+ # * `#name`
33
+ # * `#locale`
34
+ # * `.find_by_name!`
35
+ #
36
+ # _user_:
37
+ # * `.find_by_uid!`
38
+ #
39
+ # _course_:
40
+ # * `.find_by_slug!`
41
+ #
29
42
  define_singleton_method("#{klass}_class") do
30
43
  begin
31
44
  config["#{klass}_class"] ||= config["#{klass}_class_name"].constantize
@@ -38,12 +51,13 @@ end
38
51
 
39
52
  require_relative './platform/notifiable'
40
53
 
54
+ require_relative './platform/global'
41
55
  require_relative './platform/domain'
42
56
  require_relative './platform/model'
43
57
  require_relative './platform/locale'
44
58
  require_relative './platform/course'
45
- require_relative './platform/user'
46
59
  require_relative './platform/organization'
60
+ require_relative './platform/user'
47
61
  require_relative './platform/organization_mapping'
48
62
  require_relative './platform/application'
49
63
  require_relative './platform/web_framework'
@@ -53,4 +53,4 @@ class Mumukit::Platform::Application
53
53
  organization_mapping.organic_uri(uri, organization)
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -1,7 +1,11 @@
1
1
  module Mumukit::Platform::Course
2
+ extend Mumukit::Platform::Global
3
+
2
4
  def self.find_by_slug!(slug)
3
5
  Mumukit::Platform.course_class.find_by_slug!(slug)
4
6
  end
5
- end
6
7
 
7
- require_relative './course/helpers'
8
+ def self.__global_thread_variable_key__
9
+ :course
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ module Mumukit::Platform::Global
2
+ def switch!(global)
3
+ raise "#{__global_thread_variable_key__} must not be nil" unless global
4
+ Thread.current[__global_thread_variable_key__] = global
5
+ end
6
+
7
+ def leave!
8
+ Thread.current[__global_thread_variable_key__] = nil
9
+ end
10
+
11
+ def current
12
+ Thread.current[__global_thread_variable_key__] || raise("#{__global_thread_variable_key__} not selected")
13
+ end
14
+
15
+ def current?
16
+ !!Thread.current[__global_thread_variable_key__]
17
+ end
18
+ end
19
+
@@ -2,6 +2,7 @@ module Mumukit::Platform::Locale
2
2
  SPECS = {
3
3
  en: { facebook_code: :en_US, auth0_code: :en, name: 'English' },
4
4
  es: { facebook_code: :es_LA, auth0_code: :es, name: 'Español' },
5
+ 'es-CL': { facebook_code: :es_LA, auth0_code: :es, name: 'Español chileno' },
5
6
  pt: { facebook_code: :pt_BR, auth0_code: 'pt-br', name: 'Português' }
6
7
  }.with_indifferent_access
7
8
 
@@ -1,31 +1,30 @@
1
1
  module Mumukit::Platform::Organization
2
- def self.switch!(organization)
3
- raise 'Organization must not be nil' unless organization
4
- Thread.current[:organization] = organization
2
+ extend Mumukit::Platform::Global
3
+
4
+ def self.current_locale
5
+ Thread.current[:organization]&.locale || 'en'
5
6
  end
6
7
 
7
- def self.leave!
8
- Thread.current[:organization] = nil
8
+ def self.find_by_name!(name)
9
+ Mumukit::Platform.organization_class.find_by_name!(name)
9
10
  end
10
11
 
11
- def self.current
12
- Thread.current[:organization] || raise('organization not selected')
12
+ def self.__global_thread_variable_key__
13
+ :organization
13
14
  end
14
15
 
15
- def self.current?
16
- !!Thread.current[:organization]
16
+ ## Name validation
17
+
18
+ def self.valid_name?(name)
19
+ !!(name =~ anchored_valid_name_regex)
17
20
  end
18
21
 
19
- def self.current_locale
20
- Thread.current[:organization]&.locale || 'en'
22
+ def self.anchored_valid_name_regex
23
+ /\A#{valid_name_regex}\z/
21
24
  end
22
25
 
23
- def self.find_by_name!(name)
24
- Mumukit::Platform.organization_class.find_by_name!(name)
26
+ def self.valid_name_regex
27
+ /([-a-z0-9_]+(\.[-a-z0-9_]+)*)?/
25
28
  end
26
29
  end
27
30
 
28
- require_relative './organization/settings'
29
- require_relative './organization/profile'
30
- require_relative './organization/theme'
31
- require_relative './organization/helpers'
@@ -9,10 +9,10 @@ module Mumukit::Platform::OrganizationMapping
9
9
 
10
10
  def self.parse(name)
11
11
  mapping = name.try { |it| it.strip.downcase }
12
- if mapping.blank? || mapping == 'subdomain'
13
- Subdomain
14
- elsif mapping == 'path'
12
+ if mapping.blank? || mapping == 'path'
15
13
  Path
14
+ elsif mapping == 'subdomain'
15
+ Subdomain
16
16
  else
17
17
  raise "Unrecognized organization mapping #{mapping}"
18
18
  end
@@ -50,11 +50,11 @@ module Mumukit::Platform::OrganizationMapping
50
50
  end
51
51
 
52
52
  def self.organization_name(request, _domain)
53
- request.path.split('/')[1]
53
+ request.path_info.split('/')[1]
54
54
  end
55
55
 
56
56
  def self.organic_uri(uri, organization)
57
- uri.subroute(organization)
57
+ uri.tenantize organization
58
58
  end
59
59
 
60
60
  def self.path_under_namespace?(organization_name, path, namespace)
@@ -8,11 +8,11 @@ class URI::HTTP
8
8
  rebuild(host: new_host)
9
9
  end
10
10
 
11
- def subroute(route)
12
- if path.start_with? '/'
13
- new_path = "/#{route}#{path}"
11
+ def tenantize(route)
12
+ if path.end_with? '/'
13
+ new_path = "#{path}#{route}/"
14
14
  else
15
- new_path = "/#{route}/#{path}"
15
+ new_path = "#{path}/#{route}/"
16
16
  end
17
17
  rebuild(path: new_path)
18
18
  end
@@ -3,5 +3,3 @@ module Mumukit::Platform::User
3
3
  Mumukit::Platform.user_class.find_by_uid!(uid)
4
4
  end
5
5
  end
6
-
7
- require_relative './user/helpers'
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Platform
3
- VERSION = '4.2.0'
3
+ VERSION = '6.0.0'
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ module Mumukit::Platform::WebFramework
21
21
  def self.tenant_scope_options
22
22
  {
23
23
  defaults: { tenant: lazy_string { Mumukit::Platform.current_organization_name } },
24
- constraints: { tenant: Mumukit::Platform::Organization::Helpers.valid_name_regex }
24
+ constraints: { tenant: Mumukit::Platform::Organization.valid_name_regex }
25
25
  }
26
26
  end
27
27
  end
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency 'mumukit-nuntius', '~> 6.0'
25
25
  spec.add_dependency 'mumukit-core', '~> 1.2'
26
26
  spec.add_dependency 'mumukit-auth', '~> 7.6'
27
- spec.add_dependency 'mumukit-bridge', '~> 3.5'
27
+ spec.add_dependency 'mumukit-bridge', '>= 3.5', '< 5'
28
28
  spec.add_dependency 'activemodel', '>= 4.0'
29
29
 
30
- spec.add_development_dependency 'bundler', '~> 1.14'
31
- spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'bundler', '~> 2.0'
31
+ spec.add_development_dependency 'rake', '~> 12.3'
32
32
  spec.add_development_dependency 'rspec', '~> 3.0'
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit-platform
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-10 00:00:00.000000000 Z
11
+ date: 2020-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit-nuntius
@@ -56,16 +56,22 @@ dependencies:
56
56
  name: mumukit-bridge
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.5'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '5'
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - "~>"
69
+ - - ">="
67
70
  - !ruby/object:Gem::Version
68
71
  version: '3.5'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '5'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: activemodel
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +92,28 @@ dependencies:
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '1.14'
95
+ version: '2.0'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '1.14'
102
+ version: '2.0'
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: rake
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: '10.0'
109
+ version: '12.3'
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
114
  - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: '10.0'
116
+ version: '12.3'
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: rspec
113
119
  requirement: !ruby/object:Gem::Requirement
@@ -144,20 +150,15 @@ files:
144
150
  - lib/mumukit/platform/application.rb
145
151
  - lib/mumukit/platform/bridge.rb
146
152
  - lib/mumukit/platform/course.rb
147
- - lib/mumukit/platform/course/helpers.rb
148
153
  - lib/mumukit/platform/domain.rb
154
+ - lib/mumukit/platform/global.rb
149
155
  - lib/mumukit/platform/locale.rb
150
156
  - lib/mumukit/platform/model.rb
151
157
  - lib/mumukit/platform/notifiable.rb
152
158
  - lib/mumukit/platform/organization.rb
153
- - lib/mumukit/platform/organization/helpers.rb
154
- - lib/mumukit/platform/organization/profile.rb
155
- - lib/mumukit/platform/organization/settings.rb
156
- - lib/mumukit/platform/organization/theme.rb
157
159
  - lib/mumukit/platform/organization_mapping.rb
158
160
  - lib/mumukit/platform/uri.rb
159
161
  - lib/mumukit/platform/user.rb
160
- - lib/mumukit/platform/user/helpers.rb
161
162
  - lib/mumukit/platform/version.rb
162
163
  - lib/mumukit/platform/web_framework.rb
163
164
  - lib/mumukit/platform/with_applications.rb
@@ -184,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
185
  - !ruby/object:Gem::Version
185
186
  version: '0'
186
187
  requirements: []
187
- rubygems_version: 3.0.3
188
+ rubygems_version: 3.0.8
188
189
  signing_key:
189
190
  specification_version: 4
190
191
  summary: Shared Mumuki Platform Components
@@ -1,43 +0,0 @@
1
- module Mumukit::Platform::Course::Helpers
2
- include Mumukit::Platform::Notifiable
3
-
4
- ## Implementors must declare the following methods:
5
- #
6
- # * slug
7
- # * shifts
8
- # * code
9
- # * days
10
- # * period
11
- # * description
12
-
13
- def platform_class_name
14
- :Course
15
- end
16
-
17
- ## API Exposure
18
-
19
- def to_param
20
- slug
21
- end
22
-
23
- ## Resource Hash
24
-
25
- def self.slice_resource_h(resource_h)
26
- resource_h.slice(:slug, :shifts, :code, :days, :period, :description)
27
- end
28
-
29
- def to_resource_h
30
- {
31
- slug: slug,
32
- shifts: shifts,
33
- code: code,
34
- days: days,
35
- period: period,
36
- description: description
37
- }.except(*protected_resource_fields).compact
38
- end
39
-
40
- def protected_resource_fields
41
- []
42
- end
43
- end
@@ -1,112 +0,0 @@
1
- module Mumukit::Platform::Organization::Helpers
2
- extend ActiveSupport::Concern
3
- include Mumukit::Platform::Notifiable
4
-
5
- ## Implementors must declare the following methods:
6
- #
7
- # * name
8
- # * book
9
- # * profile
10
- # * settings
11
- # * theme
12
-
13
- included do
14
- delegate *Mumukit::Platform::Organization::Theme.accessors, to: :theme
15
- delegate *Mumukit::Platform::Organization::Settings.accessors, :private?, :login_settings, to: :settings
16
- delegate *Mumukit::Platform::Organization::Profile.accessors, :locale_json, to: :profile
17
- end
18
-
19
- def platform_class_name
20
- :Organization
21
- end
22
-
23
- def slug
24
- Mumukit::Auth::Slug.join_s name
25
- end
26
-
27
- def central?
28
- name == 'central'
29
- end
30
-
31
- def test?
32
- name == 'test'
33
- end
34
-
35
- def base?
36
- name == 'base'
37
- end
38
-
39
- def switch!
40
- Mumukit::Platform::Organization.switch! self
41
- end
42
-
43
- def to_s
44
- name
45
- end
46
-
47
- def url_for(path)
48
- Mumukit::Platform.application.organic_url_for(name, path)
49
- end
50
-
51
- def url
52
- url_for '/'
53
- end
54
-
55
- def domain
56
- Mumukit::Platform.application.organic_domain(name)
57
- end
58
-
59
- ## API Exposure
60
-
61
- def to_param
62
- name
63
- end
64
-
65
- ## Name validation
66
-
67
- def self.valid_name?(name)
68
- !!(name =~ anchored_valid_name_regex)
69
- end
70
-
71
- def self.anchored_valid_name_regex
72
- /\A#{valid_name_regex}\z/
73
- end
74
-
75
- def self.valid_name_regex
76
- /([-a-z0-9_]+(\.[-a-z0-9_]+)*)?/
77
- end
78
-
79
- ## Resource Hash
80
-
81
- def self.slice_resource_h(resource_h)
82
- resource_h.slice(:name, :book, :profile, :settings, :theme)
83
- end
84
-
85
- def to_resource_h
86
- {
87
- name: name,
88
- book: book.slug,
89
- profile: profile,
90
- settings: settings,
91
- theme: theme
92
- }.except(*protected_resource_fields).compact
93
- end
94
-
95
- def protected_resource_fields
96
- []
97
- end
98
-
99
- module ClassMethods
100
- def current
101
- Mumukit::Platform::Organization.current
102
- end
103
-
104
- def parse(json)
105
- json
106
- .slice(:name)
107
- .merge(theme: Mumukit::Platform::Organization::Theme.parse(json[:theme]))
108
- .merge(settings: Mumukit::Platform::Organization::Settings.parse(json[:settings]))
109
- .merge(profile: Mumukit::Platform::Organization::Profile.parse(json[:profile]))
110
- end
111
- end
112
- end
@@ -1,39 +0,0 @@
1
- class Mumukit::Platform::Organization::Profile < Mumukit::Platform::Model
2
- LOCALES = Mumukit::Platform::Locale::SPECS
3
-
4
- model_attr_accessor :logo_url,
5
- :banner_url,
6
- :favicon_url,
7
- :breadcrumb_image_url,
8
- :open_graph_image_url,
9
- :locale,
10
- :description,
11
- :contact_email,
12
- :terms_of_service,
13
- :community_link,
14
- :errors_explanations
15
-
16
- def locale_json
17
- locale_h.to_json
18
- end
19
-
20
- def locale_h
21
- Mumukit::Platform::Locale::SPECS[locale]
22
- end
23
-
24
- def logo_url
25
- @logo_url ||= 'https://mumuki.io/logo-alt-large.png' # Best image size: 350x75
26
- end
27
-
28
- def banner_url
29
- @banner_url || logo_url # Best image size: 350x75
30
- end
31
-
32
- def favicon_url
33
- @favicon_url ||= '/favicon.ico' # Best image size: 16x16, 32x32 or 48x48
34
- end
35
-
36
- def open_graph_image_url
37
- @open_graph_image_url ||= Mumukit::Platform.application.url_for("logo-alt.png") # Best image size: 256x256
38
- end
39
- end
@@ -1,25 +0,0 @@
1
- class Mumukit::Platform::Organization::Settings < Mumukit::Platform::Model
2
- model_attr_accessor :login_methods,
3
- :login_provider,
4
- :login_provider_settings,
5
- :forum_discussions_minimal_role,
6
- :raise_hand_enabled?,
7
- :feedback_suggestions_enabled?,
8
- :public?,
9
- :embeddable?,
10
- :immersive?,
11
- :forum_enabled?,
12
- :report_issue_enabled?
13
-
14
- def private?
15
- !public?
16
- end
17
-
18
- def login_methods
19
- @login_methods ||= ['user_pass']
20
- end
21
-
22
- def forum_discussions_minimal_role
23
- (@forum_discussions_minimal_role || 'student').to_sym
24
- end
25
- end
@@ -1,4 +0,0 @@
1
- class Mumukit::Platform::Organization::Theme < Mumukit::Platform::Model
2
- model_attr_accessor :theme_stylesheet,
3
- :extension_javascript
4
- end
@@ -1,142 +0,0 @@
1
- module Mumukit::Platform::User::Helpers
2
- include Mumukit::Auth::Roles
3
- include Mumukit::Platform::Notifiable
4
-
5
- extend Gem::Deprecate
6
-
7
- ## Implementors must declare the following methods:
8
- #
9
- # * permissions
10
- # * uid
11
- # * social_id
12
- # * image_url
13
- # * email
14
- # * first_name
15
- # * last_name
16
-
17
- ## Permissions
18
-
19
- delegate :has_role?,
20
- :add_permission!,
21
- :remove_permission!,
22
- :has_permission?,
23
- :has_permission_delegation?,
24
- :protect!,
25
- :protect_delegation!,
26
- :protect_permissions_assignment!,
27
- to: :permissions
28
-
29
- def platform_class_name
30
- :User
31
- end
32
-
33
- def merge_permissions!(new_permissions)
34
- self.permissions = permissions.merge(new_permissions)
35
- end
36
-
37
- (Mumukit::Auth::Roles::ROLES - [:writer, :editor, :owner] + [:discusser]).each do |role|
38
- role_of = "#{role}_of?"
39
- role_here = "#{role}_here?"
40
-
41
- # Tells whether this user has #{role} permissions in
42
- # the given organization
43
- define_method role_of do |organization|
44
- has_permission? role, organization.slug
45
- end
46
-
47
- # Tells whether this user has #{role} permissions in
48
- # the current organization
49
- define_method role_here do
50
- send role_of, Mumukit::Platform::Organization.current
51
- end
52
- end
53
-
54
- # Tells whether this user has forum discusser permissions in
55
- # the given organization
56
- def discusser_of?(organization)
57
- has_permission? organization.forum_discussions_minimal_role, organization.slug
58
- end
59
-
60
- (Mumukit::Auth::Roles::ROLES - [:owner]).each do |role|
61
-
62
- # Assignes the #{role} role to this user
63
- # for the given slug
64
- define_method "make_#{role}_of!" do |slug|
65
- add_permission! role, slug
66
- end
67
- end
68
-
69
- ## Profile
70
-
71
- def full_name
72
- "#{first_name} #{last_name}"
73
- end
74
-
75
- alias_method :name, :full_name
76
-
77
- def profile_completed?
78
- [first_name, last_name].all? &:present?
79
- end
80
-
81
- def to_s
82
- "#{full_name} <#{email}> [#{uid}]"
83
- end
84
-
85
- ## Accesible organizations
86
-
87
- def student_granted_organizations
88
- permissions.student_granted_organizations.map do |org|
89
- Mumukit::Platform::Organization.find_by_name!(org) rescue nil
90
- end.compact
91
- end
92
-
93
- def has_student_granted_organizations?
94
- student_granted_organizations.present?
95
- end
96
-
97
- [[:accessible_organizations, :student_granted_organizations],
98
- [:has_accessible_organizations?, :has_student_granted_organizations?]].each do |it, replacement|
99
- alias_method it, replacement
100
- deprecate it, replacement, 2019, 6
101
- end
102
-
103
- def main_organization
104
- student_granted_organizations.first
105
- end
106
-
107
- def has_main_organization?
108
- student_granted_organizations.length == 1
109
- end
110
-
111
- def has_immersive_main_organization?
112
- !!main_organization.try(&:immersive?)
113
- end
114
-
115
- ## API Exposure
116
-
117
- def to_param
118
- uid
119
- end
120
-
121
- ## Resource Hash
122
-
123
- def self.slice_resource_h(resource_h)
124
- resource_h.slice(:uid, :social_id, :image_url, :email, :first_name, :last_name, :permissions)
125
- end
126
-
127
- def to_resource_h
128
- {
129
- uid: uid,
130
- social_id: social_id,
131
- image_url: image_url,
132
- email: email,
133
- first_name: first_name,
134
- last_name: last_name,
135
- permissions: permissions
136
- }.except(*protected_resource_fields).compact
137
- end
138
-
139
- def protected_resource_fields
140
- []
141
- end
142
- end