mumukit-platform 4.2.0 → 5.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: a1e1ce06ac9d7055da2a3f86b3a865630a7788e182e0c021485c9b2b638df543
4
+ data.tar.gz: d1ab26c3c29648fea155c0aef57315b57e1405efab03b44fadfa2f8e06c0724c
5
5
  SHA512:
6
- metadata.gz: ff19191a1dbca41064ecf36df3e0e945546ad30a179a53bd3f763552c86cb65e9ccb8819f755c7b1fff5bedc0571c7ef25bb8eb2eecb5f734c47184567e926d4
7
- data.tar.gz: a76f6ca3e5b593d77f748e9205503d2986808eade31f2207e7e30ffdf880b027237e69d18245d1b5e2f8972fb8d2884cf1e31cbf8160f4561a6c2f2aaadb86ea
6
+ metadata.gz: 74adaec00a74e0774e0136b6295462a0f47d26380b915cdef19e04a1a7458de90987a599c25c6843362d21bd1626819e5fcfaed6b23d21e9f0b109d4eae77dac
7
+ data.tar.gz: d40805aa710719fef5c0a78a306787946f312e8d685ed927501696045e1754a3a6f56c855ec3d8f8e9fe02c1a92fd1bf9b8661a00b373576a22ccd0bba65d7b5
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.6.3
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.1
4
+ - 2.6.3
5
5
  before_install: gem install bundler -v 1.14.2
6
6
  deploy:
7
7
  provider: rubygems
data/README.md CHANGED
@@ -23,6 +23,23 @@ 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
+ * `.for_profile`
37
+ * `.find_by_uid!`
38
+
39
+ _course_:
40
+ * `.find_by_slug!`
41
+
42
+
26
43
  ## Contributing
27
44
 
28
45
  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 +47,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/mumuki
30
47
  ## License
31
48
 
32
49
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
33
-
@@ -26,6 +26,20 @@ 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
+ # * `.for_profile`
38
+ # * `.find_by_uid!`
39
+ #
40
+ # _course_:
41
+ # * `.find_by_slug!`
42
+ #
29
43
  define_singleton_method("#{klass}_class") do
30
44
  begin
31
45
  config["#{klass}_class"] ||= config["#{klass}_class_name"].constantize
@@ -42,8 +56,8 @@ 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'
@@ -3,5 +3,3 @@ module Mumukit::Platform::Course
3
3
  Mumukit::Platform.course_class.find_by_slug!(slug)
4
4
  end
5
5
  end
6
-
7
- require_relative './course/helpers'
@@ -25,7 +25,3 @@ module Mumukit::Platform::Organization
25
25
  end
26
26
  end
27
27
 
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
@@ -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 = '5.0.0'
4
4
  end
5
5
  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: 5.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: 2019-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit-nuntius
@@ -144,20 +144,14 @@ files:
144
144
  - lib/mumukit/platform/application.rb
145
145
  - lib/mumukit/platform/bridge.rb
146
146
  - lib/mumukit/platform/course.rb
147
- - lib/mumukit/platform/course/helpers.rb
148
147
  - lib/mumukit/platform/domain.rb
149
148
  - lib/mumukit/platform/locale.rb
150
149
  - lib/mumukit/platform/model.rb
151
150
  - lib/mumukit/platform/notifiable.rb
152
151
  - 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
152
  - lib/mumukit/platform/organization_mapping.rb
158
153
  - lib/mumukit/platform/uri.rb
159
154
  - lib/mumukit/platform/user.rb
160
- - lib/mumukit/platform/user/helpers.rb
161
155
  - lib/mumukit/platform/version.rb
162
156
  - lib/mumukit/platform/web_framework.rb
163
157
  - lib/mumukit/platform/with_applications.rb
@@ -184,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
178
  - !ruby/object:Gem::Version
185
179
  version: '0'
186
180
  requirements: []
187
- rubygems_version: 3.0.3
181
+ rubygems_version: 3.0.4
188
182
  signing_key:
189
183
  specification_version: 4
190
184
  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