lesli 5.0.20 → 5.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -0
  3. data/app/assets/images/lesli/brand/register-background.jpg +0 -0
  4. data/app/assets/stylesheets/lesli/application.css +191 -1
  5. data/app/helpers/lesli/assets_helper.rb +23 -59
  6. data/app/models/concerns/lesli/account_initializer.rb +79 -0
  7. data/app/models/concerns/lesli/user_activities.rb +165 -0
  8. data/app/models/concerns/lesli/user_extensions.rb +133 -0
  9. data/app/models/concerns/lesli/user_security.rb +220 -0
  10. data/app/models/lesli/user.rb +15 -15
  11. data/app/services/lesli/role_service.rb +4 -4
  12. data/app/views/lesli/abouts/welcome.html.erb +11 -11
  13. data/app/views/lesli/errors/unauthorized.html.erb +1 -1
  14. data/app/views/lesli/layouts/application-devise.html.erb +3 -6
  15. data/app/views/lesli/layouts/application-lesli.html.erb +4 -5
  16. data/app/views/lesli/layouts/application-public.html.erb +2 -16
  17. data/app/views/lesli/partials/_application-analytics.html.erb +4 -6
  18. data/app/views/lesli/partials/_application-head.html.erb +4 -4
  19. data/app/views/lesli/partials/{_application-lesli-scss.html.erb → _application-lesli-css.html.erb} +4 -10
  20. data/app/views/lesli/partials/{_application-data.html.erb → _application-lesli-data.html.erb} +4 -1
  21. data/app/views/lesli/partials/_application-lesli-header.html.erb +0 -15
  22. data/app/views/lesli/partials/_application-lesli-javascript.html.erb +3 -5
  23. data/db/seed/accounts.rb +1 -1
  24. data/db/seed/users.rb +1 -1
  25. data/db/seeds.rb +6 -6
  26. data/lib/lesli/engine.rb +3 -4
  27. data/lib/lesli/version.rb +2 -2
  28. data/lib/rspec/helpers/lesli_helper.rb +11 -0
  29. data/lib/tasks/lesli/controllers.rake +1 -1
  30. data/lib/tasks/lesli/db.rake +26 -26
  31. data/lib/tasks/lesli_tasks.rake +0 -2
  32. metadata +19 -41
  33. data/app/models/concerns/account_initializer.rb +0 -82
  34. data/app/models/concerns/user_activities.rb +0 -163
  35. data/app/models/concerns/user_extensions.rb +0 -152
  36. data/app/models/concerns/user_security.rb +0 -277
  37. data/app/operators/lesli/user_registration_operator.rb +0 -122
  38. data/app/views/lesli/partials/_application-lesli-chatbox.html.erb +0 -35
  39. data/app/views/lesli/partials/_application-lesli-panels.html.erb +0 -58
  40. data/app/views/lesli/partials/_application-public-footer.html.erb +0 -51
  41. data/app/views/lesli/partials/_application-public-javascript.html.erb +0 -49
  42. data/app/views/lesli/partials/_application-public-scss.html.erb +0 -35
  43. data/config/initializers/devise_rails_8_patch.rb +0 -8
@@ -1,9 +1,8 @@
1
- <%
2
- =begin
1
+ <%#
3
2
 
4
3
  Lesli
5
4
 
6
- Copyright (c) 2023, Lesli Technologies, S. A.
5
+ Copyright (c) 2025, Lesli Technologies, S. A.
7
6
 
8
7
  This program is free software: you can redistribute it and/or modify
9
8
  it under the terms of the GNU General Public License as published by
@@ -29,12 +28,8 @@ Building a better future, one line of code at a time.
29
28
 
30
29
  // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
31
30
  // ·
32
- =end
33
31
  %>
34
32
 
35
- <%# Hide vue until vue finishes compilation %>
36
- <%# <style>[v-cloak] { display: none !important; }</style> %>
37
-
38
33
 
39
34
  <%
40
35
  # Defining color customization
@@ -55,6 +50,5 @@ Building a better future, one line of code at a time.
55
50
 
56
51
 
57
52
  <%# Loading stylesheets %>
58
- <%= stylesheet_link_tag lesli_application_stylesheet_path(:lesli_assets), media: "all" %>
59
- <%= stylesheet_link_tag lesli_application_stylesheet_path(), media: "all" %>
60
-
53
+ <%= stylesheet_link_tag(lesli_asset_path(:lesli_assets, 'templates/application'), media: "all") %>
54
+ <%= stylesheet_link_tag(lesli_asset_path(), media: "all") %>
@@ -32,7 +32,10 @@ Building a better future, one line of code at a time.
32
32
 
33
33
  <%
34
34
 
35
- @lesli[:tickets] = 0
35
+ # Defining color customization
36
+ # colors will be override with the ones defined in the database if custom colors exists
37
+ # if there is no custom colors defined, the var() function will return the lesli colors
38
+ #@lesli.dig(:customization, :colors) || {}
36
39
  @lesli[:notifications] = Lesli::Courier.new(:lesli_bell, 0).from(:notification_service, current_user).call(:count)
37
40
 
38
41
  %>
@@ -58,21 +58,6 @@ Building a better future, one line of code at a time.
58
58
  <div class="navbar-menu" :class="{ 'is-active': navActive }">
59
59
  <div class="navbar-end is-flex is-justify-content-center">
60
60
 
61
- <!-- tickets -->
62
- <div class="navbar-item">
63
- <% if defined?(LesliSupport) %>
64
- <%= link_to(
65
- lesli_support.tickets_path,
66
- :class => "header-indicator",
67
- :data => { turbo_frame: '_top' }) do %>
68
- <span class="ri-ticket-2-line"></span>
69
- <% if @lesli[:tickets] > 0 %>
70
- <span class="count"></span>
71
- <% end %>
72
- <% end %>
73
- <% end %>
74
- </div>
75
-
76
61
  <!-- notifications -->
77
62
  <div class="navbar-item">
78
63
  <% if defined?(LesliBell) %>
@@ -1,9 +1,8 @@
1
- <%
2
- =begin
1
+ <%#
3
2
 
4
3
  Lesli
5
4
 
6
- Copyright (c) 2023, Lesli Technologies, S. A.
5
+ Copyright (c) 2025, Lesli Technologies, S. A.
7
6
 
8
7
  This program is free software: you can redistribute it and/or modify
9
8
  it under the terms of the GNU General Public License as published by
@@ -29,11 +28,10 @@ Building a better future, one line of code at a time.
29
28
 
30
29
  // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
31
30
  // ·
32
- =end
33
31
  %>
34
32
 
35
33
  <%= javascript_importmap_tags %>
36
- <%= javascript_include_tag("lesli_assets/application.js", :defer => "defer") %>
34
+ <%= javascript_include_tag(lesli_asset_path(:lesli_assets, 'application'), :defer => "defer") %>
37
35
  <%= yield(:application_lesli_javascript) %>
38
36
  <%#
39
37
  <script src="https://js.honeybadger.io/v3.2/honeybadger.min.js" type="text/javascript"></script>
data/db/seed/accounts.rb CHANGED
@@ -50,5 +50,5 @@ account = Lesli::Account.find_or_create_by(email: company[:email]) do |account|
50
50
  end
51
51
 
52
52
  # print some separators so will be easy to find these messages later
53
- L2.br(5); L2.br; L2.line; L2.line; L2.line; L2.line;
53
+ L2.br(3);
54
54
  L2.success("Account #{ account.name } <#{ account.email }> successfully created!")
data/db/seed/users.rb CHANGED
@@ -78,4 +78,4 @@ L2.success(
78
78
 
79
79
 
80
80
  # print some separators so will be easy to find these messages later
81
- L2.line; L2.line; L2.line; L2.line; L2.br(5);L2.br(5);
81
+ L2.br(2);
data/db/seeds.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Lesli
4
4
 
5
- Copyright (c) 2023, Lesli Technologies, S. A.
5
+ Copyright (c) 2025, Lesli Technologies, S. A.
6
6
 
7
7
  This program is free software: you can redistribute it and/or modify
8
8
  it under the terms of the GNU General Public License as published by
@@ -17,21 +17,21 @@ GNU General Public License for more details.
17
17
  You should have received a copy of the GNU General Public License
18
18
  along with this program. If not, see http://www.gnu.org/licenses/.
19
19
 
20
- Lesli · Your Smart Business Assistant.
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
21
 
22
- Made with ♥ by https://www.lesli.tech
22
+ Made with ♥ by LesliTech
23
23
  Building a better future, one line of code at a time.
24
24
 
25
25
  @contact hello@lesli.tech
26
- @website https://lesli.tech
26
+ @website https://www.lesli.tech
27
27
  @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
28
 
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
30
  // ·
31
31
  =end
32
32
 
33
33
 
34
- L2.msg("Lesli", "Version: #{Lesli::VERSION}", "Build: #{Lesli::BUILD}")
34
+ L2.info("Loading seeds for: Lesli #{Lesli::VERSION}")
35
35
 
36
36
 
37
37
  # including tools for seeders
data/lib/lesli/engine.rb CHANGED
@@ -36,9 +36,11 @@ require "kaminari"
36
36
 
37
37
  # · Tools used to build the Lesli Framework
38
38
  require "L2"
39
- require "useragent"
39
+ #require "useragent"
40
40
  require "acts_as_paranoid"
41
41
 
42
+ # The hole Lesli ecosystem depends on current_user, so we
43
+ # include the dependency in the core
42
44
  require "devise"
43
45
 
44
46
  require "lesli_date"
@@ -73,9 +75,6 @@ module Lesli
73
75
  end
74
76
  end
75
77
 
76
-
77
- #config.view_component.view_component_path = root.join("app","components")
78
-
79
78
 
80
79
  # Lesli Framework configuration
81
80
 
data/lib/lesli/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Lesli
2
- VERSION = "5.0.20"
3
- BUILD = "1754023334"
2
+ VERSION = "5.0.22"
3
+ BUILD = "1755006918"
4
4
  end
@@ -52,3 +52,14 @@ module LesliHelper
52
52
  Rack::Test::UploadedFile.new(Rails.root.join(path))
53
53
  end
54
54
  end
55
+
56
+ # Devise Rails 8 patch
57
+
58
+ require 'devise'
59
+
60
+ module Devise
61
+ def self.mappings
62
+ Rails.application.try(:reload_routes_unless_loaded)
63
+ @@mappings
64
+ end
65
+ end
@@ -36,7 +36,7 @@ namespace :lesli do
36
36
 
37
37
  desc "Scan new routes added and create role privileges"
38
38
  task build: :environment do
39
- L2.msg("Lesli: Registering engines, controllers and actions")
39
+ L2.info("Lesli: Registering engines, controllers and actions")
40
40
  Lesli::ControllerOperator.new.build
41
41
  end
42
42
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Lesli
4
4
 
5
- Copyright (c) 2023, Lesli Technologies, S. A.
5
+ Copyright (c) 2025, Lesli Technologies, S. A.
6
6
 
7
7
  This program is free software: you can redistribute it and/or modify
8
8
  it under the terms of the GNU General Public License as published by
@@ -39,16 +39,8 @@ namespace :lesli do
39
39
  drop()
40
40
  create()
41
41
  migrate()
42
- prepare()
43
42
  seed()
44
- status()
45
- end
46
-
47
- desc "Migrate, seed & prepare the Lesli database (development only)"
48
- task :dev => :environment do |task, args|
49
- migrate()
50
43
  prepare()
51
- seed()
52
44
  status()
53
45
  end
54
46
 
@@ -84,13 +76,20 @@ namespace :lesli do
84
76
  L2.m("Drop the Lesli database (development only)")
85
77
 
86
78
  Rake::Task['db:drop'].invoke
79
+ L2.info("Databases deleted")
80
+
81
+ schema_file = Rails.root.join('db', 'schema.rb')
82
+ if File.exist?(schema_file)
83
+ File.delete(schema_file)
84
+ L2.info("Schema.rb file deleted")
85
+ end
87
86
  end
88
87
 
89
88
  # Create the Lesli database (development only)
90
89
  def create
91
90
 
92
91
  # print a message to let the users show the action running
93
- L2.m("Create the Lesli database (development only)")
92
+ L2.m("Create the Lesli database")
94
93
 
95
94
  Rake::Task['db:create'].invoke
96
95
  end
@@ -99,7 +98,7 @@ namespace :lesli do
99
98
  def migrate
100
99
 
101
100
  # print a message to let the users show the action running
102
- L2.m("Migrate the Lesli database")
101
+ L2.msg("Migrate the Lesli database")
103
102
 
104
103
  Rake::Task['db:migrate'].invoke
105
104
  end
@@ -111,15 +110,13 @@ namespace :lesli do
111
110
 
112
111
  # load main app seeders
113
112
  Rake::Task['db:seed'].invoke
113
+ L2.info("Root: Seeds executed")
114
114
 
115
115
  # load Lesli* gems seeders
116
- Lesli::Engine.load_seed
117
- LesliBell::Engine.load_seed if defined?(LesliBell)
118
- LesliAdmin::Engine.load_seed if defined?(LesliAdmin)
119
- LesliAudit::Engine.load_seed if defined?(LesliAudit)
120
- LesliLetter::Engine.load_seed if defined?(LesliLetter)
121
- LesliSupport::Engine.load_seed if defined?(LesliSupport)
122
- LesliCalendar::Engine.load_seed if defined?(LesliCalendar)
116
+ LesliSystem.engines.each do |engine, data|
117
+ next if engine == "Root"
118
+ engine.constantize::Engine.load_seed
119
+ end
123
120
  end
124
121
 
125
122
  def prepare
@@ -127,26 +124,29 @@ namespace :lesli do
127
124
  # print a message to let the users show the action running
128
125
  L2.msg("Prepare the Lesli database")
129
126
 
127
+ # scan rails routes to build the controllers index
128
+ Rake::Task['lesli:controllers:build'].invoke
129
+
130
130
  Lesli::Account.all.each do |account|
131
131
  account.initialize_account
132
132
  account.initialize_engines
133
133
  end
134
134
 
135
- # scan rails routes to build the controllers index
136
- Rake::Task['lesli:controllers:build'].invoke
137
-
138
135
  # scan rails routes to build the controllers index
139
136
  Rake::Task['lesli:shield:privileges'].invoke if defined?(LesliShield)
140
137
 
141
- # scan rails routes to build the base of translations
142
- Rake::Task['lesli:babel:scan'].invoke if defined?(LesliBabel)
138
+ if defined?(LesliBabel)
143
139
 
144
- # import local translations into LesliBabel
145
- Rake::Task['lesli:babel:import'].invoke if defined?(LesliBabel)
140
+ # scan rails routes to build the base of translations
141
+ Rake::Task['lesli:babel:scan'].invoke
142
+
143
+ # import local translations into LesliBabel
144
+ Rake::Task['lesli:babel:import'].invoke
145
+ end
146
146
  end
147
147
 
148
148
  def status
149
- # print the lesli gems
149
+ # print the lesli status
150
150
  Rake::Task['lesli:status'].invoke
151
151
  end
152
152
  end
@@ -30,8 +30,6 @@ Building a better future, one line of code at a time.
30
30
  // ·
31
31
  =end
32
32
 
33
- require "i18n-js"
34
-
35
33
  # ·
36
34
  namespace :lesli do
37
35
  namespace :babel do
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.20
4
+ version: 5.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-08-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -25,47 +24,33 @@ dependencies:
25
24
  - !ruby/object:Gem::Version
26
25
  version: '8.0'
27
26
  - !ruby/object:Gem::Dependency
28
- name: i18n-js
27
+ name: turbo-rails
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: 4.2.3
32
+ version: '2.0'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: 4.2.3
39
+ version: '2.0'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: importmap-rails
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: 2.2.0
46
+ version: '2.2'
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: 2.2.0
55
- - !ruby/object:Gem::Dependency
56
- name: turbo-rails
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
53
+ version: '2.2'
69
54
  - !ruby/object:Gem::Dependency
70
55
  name: acts_as_paranoid
71
56
  requirement: !ruby/object:Gem::Requirement
@@ -178,8 +163,8 @@ dependencies:
178
163
  - - "~>"
179
164
  - !ruby/object:Gem::Version
180
165
  version: '0.6'
181
- description: Lesli is a SaaS development framework designed to build highly scalable,
182
- secure and customizable software products.
166
+ description: "Lesli is a SaaS development framework designed to build highly scalable,
167
+ \nsecure and customizable software products.\n"
183
168
  email:
184
169
  - hello@lesli.tech
185
170
  executables: []
@@ -195,6 +180,7 @@ files:
195
180
  - app/assets/images/lesli/brand/favicon.png
196
181
  - app/assets/images/lesli/brand/favicon.svg
197
182
  - app/assets/images/lesli/brand/login-background.jpg
183
+ - app/assets/images/lesli/brand/register-background.jpg
198
184
  - app/assets/images/lesli/lesli-logo.svg
199
185
  - app/assets/javascripts/lesli/application.js
200
186
  - app/assets/stylesheets/lesli/application.css
@@ -222,11 +208,11 @@ files:
222
208
  - app/mailers/lesli/application_lesli_mailer.rb
223
209
  - app/mailers/lesli/application_mailer.rb
224
210
  - app/mailers/lesli/devise_mailer.rb
225
- - app/models/concerns/account_initializer.rb
211
+ - app/models/concerns/lesli/account_initializer.rb
226
212
  - app/models/concerns/lesli/has_activities.rb
227
- - app/models/concerns/user_activities.rb
228
- - app/models/concerns/user_extensions.rb
229
- - app/models/concerns/user_security.rb
213
+ - app/models/concerns/lesli/user_activities.rb
214
+ - app/models/concerns/lesli/user_extensions.rb
215
+ - app/models/concerns/lesli/user_security.rb
230
216
  - app/models/lesli/account.rb
231
217
  - app/models/lesli/account/detail.rb
232
218
  - app/models/lesli/account/log.rb
@@ -252,7 +238,6 @@ files:
252
238
  - app/models/lesli/user/setting.rb
253
239
  - app/operators/lesli/controller_operator.rb
254
240
  - app/operators/lesli/role_operator.rb
255
- - app/operators/lesli/user_registration_operator.rb
256
241
  - app/services/lesli/application_lesli_service.rb
257
242
  - app/services/lesli/role/action_service.rb
258
243
  - app/services/lesli/role_service.rb
@@ -271,29 +256,23 @@ files:
271
256
  - app/views/lesli/layouts/mailer.html.erb
272
257
  - app/views/lesli/layouts/mailer.text.erb
273
258
  - app/views/lesli/partials/_application-analytics.html.erb
274
- - app/views/lesli/partials/_application-data.html.erb
275
259
  - app/views/lesli/partials/_application-head.html.erb
276
260
  - app/views/lesli/partials/_application-lesli-annoouncements.html.erb
277
- - app/views/lesli/partials/_application-lesli-chatbox.html.erb
278
261
  - app/views/lesli/partials/_application-lesli-content.html.erb
262
+ - app/views/lesli/partials/_application-lesli-css.html.erb
263
+ - app/views/lesli/partials/_application-lesli-data.html.erb
279
264
  - app/views/lesli/partials/_application-lesli-footer.html.erb
280
265
  - app/views/lesli/partials/_application-lesli-header.html.erb
281
266
  - app/views/lesli/partials/_application-lesli-javascript.html.erb
282
267
  - app/views/lesli/partials/_application-lesli-navigation.html.erb
283
268
  - app/views/lesli/partials/_application-lesli-notifications.html.erb
284
- - app/views/lesli/partials/_application-lesli-panels.html.erb
285
- - app/views/lesli/partials/_application-lesli-scss.html.erb
286
269
  - app/views/lesli/partials/_application-lesli-sidebar.html.erb
287
- - app/views/lesli/partials/_application-public-footer.html.erb
288
- - app/views/lesli/partials/_application-public-javascript.html.erb
289
- - app/views/lesli/partials/_application-public-scss.html.erb
290
270
  - app/views/lesli/shared/dashboards/_edit.html.erb
291
271
  - app/views/lesli/shared/dashboards/_show.html.erb
292
272
  - app/views/lesli/wrappers/_application-devise-simple.erb
293
273
  - app/views/lesli/wrappers/_application-devise.html.erb
294
274
  - config/importmap.rb
295
275
  - config/initializers/devise.rb
296
- - config/initializers/devise_rails_8_patch.rb
297
276
  - config/initializers/lesli.rb
298
277
  - config/initializers/lesli_migration_helpers.rb
299
278
  - config/locales/devise.en.yml
@@ -394,10 +373,10 @@ files:
394
373
  - readme.md
395
374
  homepage: https://www.lesli.dev/
396
375
  licenses:
397
- - GPL-3.0
376
+ - GPL-3.0-or-later
398
377
  metadata:
399
378
  homepage_uri: https://www.lesli.dev/
400
- changelog_uri: https://github.com/LesliTech/Lesli
379
+ changelog_uri: https://github.com/LesliTech/Lesli/releases
401
380
  source_code_uri: https://github.com/LesliTech/Lesli
402
381
  bug_tracker_uri: https://github.com/LesliTech/Lesli/issues
403
382
  documentation_uri: https://www.lesli.dev/lesli/
@@ -416,8 +395,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
416
395
  - !ruby/object:Gem::Version
417
396
  version: '0'
418
397
  requirements: []
419
- rubygems_version: 3.4.19
420
- signing_key:
398
+ rubygems_version: 3.7.1
421
399
  specification_version: 4
422
400
  summary: Ruby on Rails SaaS Development Framework.
423
401
  test_files: []
@@ -1,82 +0,0 @@
1
- =begin
2
-
3
- Lesli
4
-
5
- Copyright (c) 2025, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Ruby on Rails SaaS Development Framework.
21
-
22
- Made with ♥ by LesliTech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://www.lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
- =end
32
-
33
- module AccountInitializer
34
- extend ActiveSupport::Concern
35
-
36
- # initialize minimum resources needed for the account
37
- def initialize_account
38
-
39
-
40
- # create default roles for the new account
41
- owner = self.roles
42
- .create_with({ permission_level: 2147483647 })
43
- .find_or_create_by(:name => "owner")
44
-
45
-
46
- # platform administrator role
47
- admin = self.roles
48
- .create_with({ permission_level: 100000})
49
- .find_or_create_by(name: "admin")
50
-
51
-
52
- # access only to user profile
53
- limited = self.roles
54
- .create_with({ permission_level: 10, path_default: "/administration/profile" })
55
- .find_or_create_by(name: "limited")
56
-
57
-
58
- # Add base privileges to roles
59
- Lesli::RoleOperator.new(owner).add_owner_actions
60
- Lesli::RoleOperator.new(admin).add_owner_actions
61
- Lesli::RoleOperator.new(limited).add_profile_actions
62
-
63
- end
64
-
65
-
66
- # initialize engines for new accounts
67
- def initialize_engines
68
-
69
- LesliSystem.engines.each do |engine, data|
70
-
71
- next if ["Lesli", "LesliBabel", "Root"].include?(engine)
72
-
73
- # Skip if the engine is not defined
74
- next unless Object.const_defined?(engine)
75
-
76
- #next if self.public_send(attribute).blank?
77
-
78
- # Create an associated account if the attribute is blank
79
- engine.constantize::Account.create!(account: self)
80
- end
81
- end
82
- end