lesli 5.1.12 → 5.1.14
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.
- checksums.yaml +4 -4
- data/Rakefile +3 -0
- data/app/assets/stylesheets/lesli/application.css +43 -3
- data/app/controllers/lesli/application_devise_controller.rb +9 -5
- data/app/controllers/lesli/application_lesli_controller.rb +31 -0
- data/app/controllers/lesli/items/attachments_controller.rb +200 -0
- data/app/controllers/lesli/items/discussions_controller.rb +94 -67
- data/app/controllers/lesli/items/tasks_controller.rb +132 -62
- data/app/controllers/lesli/roles_controller.rb +1 -6
- data/app/controllers/lesli/users_controller.rb +1 -5
- data/app/helpers/lesli/announcements_helper.rb +14 -0
- data/app/helpers/lesli/navigation_helper.rb +1 -1
- data/app/helpers/lesli/turbo_helper.rb +0 -18
- data/app/interfaces/lesli/responder_interface.rb +65 -38
- data/app/mailers/lesli/application_lesli_mailer.rb +34 -8
- data/app/models/concerns/lesli/account_initializer.rb +5 -37
- data/app/models/concerns/lesli/account_logs.rb +5 -16
- data/app/models/concerns/lesli/items/activities.rb +29 -33
- data/app/models/concerns/lesli/items/attachments.rb +88 -0
- data/app/models/concerns/lesli/items/discussions.rb +25 -11
- data/app/models/concerns/lesli/items/ownership.rb +27 -0
- data/app/models/concerns/lesli/items/tasks.rb +26 -6
- data/app/models/concerns/lesli/user_extensions.rb +8 -10
- data/app/models/lesli/account.rb +10 -14
- data/app/models/lesli/items/activity.rb +25 -2
- data/app/models/lesli/items/attachment.rb +117 -0
- data/app/models/lesli/items/discussion.rb +6 -2
- data/app/models/lesli/items/task.rb +3 -1
- data/app/models/lesli/role.rb +14 -2
- data/app/models/lesli/user.rb +19 -21
- data/app/operators/lesli/account_operator.rb +84 -0
- data/app/operators/lesli/resource_operator.rb +123 -0
- data/app/services/lesli/application_lesli_service.rb +33 -116
- data/app/services/lesli/resource_service.rb +12 -159
- data/app/services/lesli/role_service.rb +11 -229
- data/app/services/lesli/user_service.rb +37 -117
- data/app/views/lesli/abouts/welcome.html.erb +2 -5
- data/app/views/lesli/errors/not_found.html.erb +7 -21
- data/app/views/lesli/errors/unauthorized.html.erb +11 -27
- data/app/views/lesli/layouts/application-devise.html.erb +10 -9
- data/app/views/lesli/layouts/application-lesli.html.erb +2 -2
- data/app/views/lesli/partials/_application-lesli-announcements.html.erb +28 -0
- data/app/views/lesli/partials/_application-lesli-assets.html.erb +3 -3
- data/app/views/lesli/partials/_application-lesli-header.html.erb +8 -11
- data/app/views/lesli/partials/_application-lesli-turbo.html.erb +5 -0
- data/config/initializers/lesli.rb +10 -2
- data/config/locales/translations.en.yml +57 -14
- data/config/locales/translations.es.yml +55 -11
- data/db/migrate/v1/0000000210_create_lesli_users.rb +1 -0
- data/db/seed/accounts.rb +5 -5
- data/db/seed/users.rb +8 -16
- data/db/seed/xyz.rb +36 -17
- data/lib/generators/lesli/base_generator.rb +41 -3
- data/lib/generators/lesli/controller/controller_generator.rb +1 -1
- data/lib/generators/lesli/controller/templates/controller.rb.tt +12 -7
- data/lib/generators/lesli/model/model_generator.rb +1 -1
- data/lib/generators/lesli/resource/resource_generator.rb +290 -0
- data/lib/generators/lesli/resource/templates/controller.rb.tt +99 -0
- data/lib/generators/lesli/resource/templates/locale.en.yml.tt +13 -0
- data/lib/generators/lesli/resource/templates/migration.rb.tt +28 -0
- data/lib/generators/lesli/resource/templates/model.rb.tt +38 -0
- data/lib/generators/lesli/resource/templates/operator.rb.tt +15 -0
- data/lib/generators/lesli/resource/templates/service.rb.tt +52 -0
- data/lib/generators/lesli/resource/templates/tests/controller_test.rb.tt +14 -0
- data/lib/generators/lesli/resource/templates/tests/model_test.rb.tt +24 -0
- data/lib/generators/lesli/resource/templates/tests/operator_test.rb.tt +15 -0
- data/lib/generators/lesli/resource/templates/tests/service_test.rb.tt +17 -0
- data/lib/generators/lesli/resource/templates/views/_form.html.erb.tt +17 -0
- data/lib/generators/lesli/resource/templates/views/edit.html.erb.tt +4 -0
- data/lib/generators/lesli/resource/templates/views/index.html.erb.tt +22 -0
- data/lib/generators/lesli/resource/templates/views/new.html.erb.tt +4 -0
- data/lib/generators/lesli/resource/templates/views/show.html.erb.tt +17 -0
- data/lib/generators/lesli/scaffold/scaffold_generator.rb +4 -39
- data/lib/generators/lesli/service/service_generator.rb +1 -1
- data/lib/generators/lesli/service/templates/service.rb.tt +15 -7
- data/lib/generators/lesli/views/views_generator.rb +1 -1
- data/lib/generators/lesli_generator.rb +11 -0
- data/lib/lesli/courier.rb +66 -34
- data/lib/lesli/database_tasks.rb +145 -0
- data/lib/lesli/engine.rb +0 -4
- data/lib/lesli/router.rb +5 -2
- data/lib/lesli/version.rb +2 -2
- data/lib/migrate/items/activity_structure.rb +8 -8
- data/lib/migrate/items/attachment_structure.rb +9 -14
- data/lib/migrate/items/discussion_structure.rb +5 -5
- data/lib/migrate/items/task_structure.rb +2 -3
- data/lib/migrate/shared/account_structure.rb +1 -1
- data/lib/tasks/lesli/db.rake +16 -93
- data/lib/tasks/lesli/resources.rake +1 -1
- data/lib/tasks/lesli_tasks.rake +2 -3
- data/readme.md +6 -4
- data/test/fixtures/lesli_accounts.yml +18 -0
- data/test/fixtures/lesli_users.yml +23 -0
- metadata +39 -26
- data/app/assets/stylesheets/lesli/application.tailwind.css +0 -33
- data/app/views/lesli/partials/_application-lesli-sidebar.html.erb +0 -50
- data/config/brakeman.yml +0 -44
- data/config/initializers/devise.rb +0 -27
|
@@ -1,238 +1,20 @@
|
|
|
1
|
-
|
|
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
|
|
1
|
+
# frozen_string_literal: true
|
|
32
2
|
|
|
33
3
|
module Lesli
|
|
4
|
+
# Core exposes only the account-scoped role lookup needed by selectors.
|
|
5
|
+
# Role administration belongs to the authentication/authorization engine
|
|
6
|
+
# and is implemented by LesliShield::RoleService.
|
|
34
7
|
class RoleService < Lesli::ApplicationLesliService
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
self.resource = current_user.account.roles.find_by_id(id)
|
|
38
|
-
self
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Return a list of roles that the user is able to work with
|
|
42
|
-
# according to object level permission
|
|
43
|
-
def list(params)
|
|
44
|
-
current_user.account.roles
|
|
45
|
-
.where("permission_level <= ?", current_user.max_level_permission)
|
|
46
|
-
.order(permission_level: :desc, name: :asc)
|
|
47
|
-
.select(:id, :name, :permission_level)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# @return [Array] Paginated index of users.
|
|
52
|
-
# @description Return a paginated array of users, used mostly in frontend views
|
|
53
|
-
def index
|
|
54
|
-
|
|
55
|
-
users_subquery = <<-SQL
|
|
56
|
-
left join (
|
|
57
|
-
select
|
|
58
|
-
count(1) users,
|
|
59
|
-
role_id
|
|
60
|
-
from lesli_shield_user_roles
|
|
61
|
-
inner join lesli_users as u
|
|
62
|
-
on u.id = lesli_shield_user_roles.user_id
|
|
63
|
-
and u.deleted_at is null
|
|
64
|
-
where lesli_shield_user_roles.deleted_at is null
|
|
65
|
-
group by (role_id)
|
|
66
|
-
) users on users.role_id = lesli_roles.id
|
|
67
|
-
SQL
|
|
68
|
-
|
|
69
|
-
actions_subquery = <<-SQL
|
|
70
|
-
left join (
|
|
71
|
-
select
|
|
72
|
-
count(1) actions,
|
|
73
|
-
role_id
|
|
74
|
-
from lesli_shield_role_actions
|
|
75
|
-
group by role_id
|
|
76
|
-
) actions on actions.role_id = lesli_roles.id
|
|
77
|
-
SQL
|
|
78
|
-
|
|
79
|
-
current_user.account.roles
|
|
80
|
-
.where.not(:name => ['owner'])
|
|
81
|
-
.where("lesli_roles.permission_level <= ?", current_user.max_level_permission)
|
|
82
|
-
.joins(users_subquery)
|
|
83
|
-
.joins(actions_subquery)
|
|
84
|
-
.select(
|
|
85
|
-
:id,
|
|
86
|
-
:name,
|
|
87
|
-
:active,
|
|
88
|
-
:isolated,
|
|
89
|
-
:description,
|
|
90
|
-
:path_default,
|
|
91
|
-
:permission_level,
|
|
92
|
-
"users.users",
|
|
93
|
-
"actions.actions"
|
|
94
|
-
)
|
|
95
|
-
.page(query[:pagination][:page])
|
|
96
|
-
.per(query[:pagination][:perPage])
|
|
97
|
-
.order(permission_level: :desc, name: :asc)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# @overwrite
|
|
101
|
-
# @return {Object}
|
|
102
|
-
# @description Retrives the role
|
|
103
|
-
def show
|
|
104
|
-
self.resource
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
# @overwrite
|
|
108
|
-
# @return {Object}
|
|
109
|
-
# @param {params} Hash of the permitted attributes for a role
|
|
110
|
-
# @description Creates a new role
|
|
111
|
-
def create params
|
|
112
|
-
|
|
113
|
-
role = current_user.account.roles.new(params)
|
|
114
|
-
|
|
115
|
-
unless current_user.can_work_with_role?(role)
|
|
116
|
-
self.error(I18n.t("core.roles.messages_danger_creating_role_object_level_permission_too_high"))
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# check if user can work with that object level permission
|
|
120
|
-
if role.object_level_permission.to_f >= current_user.roles.map(&:object_level_permission).max()
|
|
121
|
-
self.error(I18n.t("core.roles.messages_danger_creating_role_object_level_permission_too_high"))
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# do not create if errors found
|
|
125
|
-
return self unless self.successful?
|
|
126
|
-
|
|
127
|
-
# Try to save role and logs if it went OK
|
|
128
|
-
if role.save
|
|
129
|
-
self.resource = role
|
|
130
|
-
#Role::Activity.log_create(current_user, self.resource)
|
|
131
|
-
else
|
|
132
|
-
self.error(role.errors.full_messages.to_sentence)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
self
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
# @overwrite
|
|
139
|
-
# @return {Object}
|
|
140
|
-
# @param {params} Hash of the permitted attributes for a role
|
|
141
|
-
# @description Updates role's attributes and saves logs if it went without problem
|
|
142
|
-
def update params
|
|
143
|
-
old_attributes = self.resource.attributes
|
|
144
|
-
|
|
145
|
-
unless self.resource.update(params)
|
|
146
|
-
self.error(self.resource.errors.full_messages.to_sentence)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
if self.successful?
|
|
150
|
-
new_attributes = self.resource.attributes
|
|
151
|
-
|
|
152
|
-
#LesliSecurity::Role::Activity.log_update(current_user, role, old_attributes, new_attributes)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
self
|
|
8
|
+
def find(id)
|
|
9
|
+
super(current_user.account.roles.find_by(id: id))
|
|
156
10
|
end
|
|
157
11
|
|
|
158
|
-
#
|
|
159
|
-
|
|
160
|
-
# @description Deletes the role
|
|
161
|
-
def destroy
|
|
162
|
-
unless self.resource.destroy
|
|
163
|
-
self.error(self.resource.errors.full_messages.to_sentence)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
if self.successful?
|
|
167
|
-
LesliSecurity::Role::Activity.log_destroy(current_user, self.resource)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
self
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
def options
|
|
174
|
-
{
|
|
175
|
-
:object_level_permissions => self.roles_with_object_level_permission
|
|
176
|
-
}
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
private
|
|
180
|
-
|
|
181
|
-
def roles_with_object_level_permission
|
|
182
|
-
levels = {}
|
|
183
|
-
|
|
184
|
-
# get all the different object level permission registered in the roles
|
|
185
|
-
existing_levels = current_user.account.roles
|
|
186
|
-
.select(:object_level_permission)
|
|
187
|
-
.order(object_level_permission: :desc)
|
|
188
|
-
.distinct
|
|
189
|
-
.map { |level| level.object_level_permission }
|
|
190
|
-
|
|
191
|
-
# Build the next available object levels
|
|
192
|
-
# basically we need to add the possibles object level permissions between the
|
|
193
|
-
# existing ones
|
|
194
|
-
existing_levels.each_with_index do |level_current, i|
|
|
195
|
-
|
|
196
|
-
level_next = 0
|
|
197
|
-
|
|
198
|
-
# get the next OLP in the list of the existing roles
|
|
199
|
-
level_next = existing_levels.to_a[i+1] unless existing_levels.to_a[i+1].nil?
|
|
200
|
-
|
|
201
|
-
# calculate the new next level, basically we get the level right in the middle
|
|
202
|
-
# between the existing levels, example:
|
|
203
|
-
# 1000 existing level
|
|
204
|
-
# 750 new projected level
|
|
205
|
-
# 500 existing level
|
|
206
|
-
level_new = (level_current + level_next) / 2
|
|
207
|
-
|
|
208
|
-
# add the levels to the levels object
|
|
209
|
-
levels[level_current] = []
|
|
210
|
-
|
|
211
|
-
next if level_next == 0
|
|
212
|
-
|
|
213
|
-
levels[level_new] = []
|
|
214
|
-
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# Get all the existing roles
|
|
12
|
+
# Return the roles available to the current user for selection.
|
|
13
|
+
def list
|
|
218
14
|
current_user.account.roles
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
# push the role grouping by the object level permission
|
|
223
|
-
levels[role.object_level_permission].push(role)
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
levels_sorted = []
|
|
227
|
-
|
|
228
|
-
levels.keys.each do |key|
|
|
229
|
-
levels_sorted.push({
|
|
230
|
-
level: key,
|
|
231
|
-
roles: levels[key]
|
|
232
|
-
})
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
levels_sorted
|
|
15
|
+
.where(permission_level: ..current_user.max_level_permission)
|
|
16
|
+
.order(permission_level: :desc, name: :asc)
|
|
17
|
+
.select(:id, :name)
|
|
236
18
|
end
|
|
237
19
|
end
|
|
238
20
|
end
|
|
@@ -32,138 +32,58 @@ Building a better future, one line of code at a time.
|
|
|
32
32
|
|
|
33
33
|
module Lesli
|
|
34
34
|
class UserService < Lesli::ApplicationLesliService
|
|
35
|
-
|
|
36
|
-
def find id
|
|
35
|
+
def find(id)
|
|
37
36
|
super(current_user.account.users.find_by(id: id))
|
|
38
37
|
end
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# inner join (
|
|
51
|
-
# select
|
|
52
|
-
# ur.users_id, string_agg(r.\"name\", ', ') role_names
|
|
53
|
-
# from user_roles ur
|
|
54
|
-
# join roles r
|
|
55
|
-
# on r.id = ur.role_id
|
|
56
|
-
# and r.name in ( #{ roles } )
|
|
57
|
-
# where ur.deleted_at is null
|
|
58
|
-
# group by ur.users_id
|
|
59
|
-
# ) roles on roles.users_id = users.id
|
|
60
|
-
# ")
|
|
61
|
-
|
|
62
|
-
users = users.joins("
|
|
63
|
-
inner join (
|
|
64
|
-
select
|
|
65
|
-
ur.users_id, string_agg(r.\"name\", ', ') role_names
|
|
66
|
-
from user_roles ur
|
|
67
|
-
join roles r
|
|
68
|
-
on r.id = ur.role_id
|
|
69
|
-
and r.name in (:roles)
|
|
70
|
-
where ur.deleted_at is null
|
|
71
|
-
group by ur.users_id
|
|
72
|
-
) roles on roles.users_id = users.id
|
|
73
|
-
")
|
|
74
|
-
.where('r.name IN (:roles)', roles: roles)
|
|
75
|
-
|
|
39
|
+
# Return only the identifier and display name needed by selectors.
|
|
40
|
+
# This read is account-scoped and intentionally not paginated.
|
|
41
|
+
def list(role: nil)
|
|
42
|
+
users = current_user.account.users.order(:first_name, :last_name, :id)
|
|
43
|
+
if role.present?
|
|
44
|
+
users = if defined?(LesliShield)
|
|
45
|
+
users.joins(:roles).where(lesli_roles: { name: role.split(",").map(&:strip) }).distinct
|
|
46
|
+
else
|
|
47
|
+
users.none
|
|
48
|
+
end
|
|
76
49
|
end
|
|
77
50
|
|
|
78
|
-
users.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"CONCAT_WS(' ', first_name, last_name) as name",
|
|
82
|
-
"COALESCE(NULLIF(alias,''), email) as alias"
|
|
83
|
-
).as_json
|
|
51
|
+
users.select(:id, :first_name, :last_name, :email).map do |user|
|
|
52
|
+
{ "id" => user.id, "name" => user.full_name }
|
|
53
|
+
end
|
|
84
54
|
end
|
|
85
55
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# Build user status
|
|
95
|
-
status_sql = "case when lesli_users.active is true then 'active' else 'inactive' end"
|
|
96
|
-
|
|
97
|
-
# Get all the roles assigned to the user
|
|
98
|
-
roles_subquery = <<-SQL
|
|
99
|
-
LEFT JOIN (
|
|
100
|
-
SELECT ur.user_id, string_agg(r.name, ', ' ORDER BY r.name) as rolenames
|
|
101
|
-
FROM lesli_shield_user_roles ur
|
|
102
|
-
JOIN lesli_roles r ON r.id = ur.role_id
|
|
103
|
-
WHERE ur.deleted_at IS NULL
|
|
104
|
-
GROUP BY ur.user_id
|
|
105
|
-
) roles ON roles.user_id = lesli_users.id
|
|
106
|
-
SQL
|
|
107
|
-
|
|
108
|
-
current_user.account.users
|
|
109
|
-
.joins(roles_subquery)
|
|
110
|
-
.select(
|
|
111
|
-
:id,
|
|
112
|
-
:email,
|
|
113
|
-
:active,
|
|
114
|
-
"#{status_sql} AS status",
|
|
115
|
-
"#{fullname_sql} AS fullname",
|
|
116
|
-
"COALESCE(roles.rolenames, '') AS rolenames",
|
|
56
|
+
def index
|
|
57
|
+
users = current_user.account.users.order(:first_name, :last_name, :id)
|
|
58
|
+
users = users.select(
|
|
59
|
+
"lesli_users.*",
|
|
60
|
+
"TRIM(CONCAT(COALESCE(first_name, ''), ' ', COALESCE(last_name, ''))) AS fullname",
|
|
61
|
+
"CASE WHEN active THEN 'active' ELSE 'inactive' END AS status",
|
|
62
|
+
"'' AS rolenames",
|
|
117
63
|
Date2.new.date_time.db_column("current_sign_in_at")
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
.
|
|
64
|
+
).page(query.dig(:pagination, :page)).per(query.dig(:pagination, :perPage))
|
|
65
|
+
|
|
66
|
+
# Preload role names instead of using database-specific string aggregation.
|
|
67
|
+
if defined?(LesliShield)
|
|
68
|
+
users = users.preload(:roles)
|
|
69
|
+
users.each { |user| user[:rolenames] = user.roles.map(&:name).join(", ") }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
users
|
|
121
73
|
end
|
|
122
74
|
|
|
123
|
-
# Creates a query that selects all user information from several tables if CloudLock is present
|
|
124
75
|
def show
|
|
125
76
|
resource
|
|
126
77
|
end
|
|
127
78
|
|
|
128
|
-
def update
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if resource.update(params)
|
|
135
|
-
|
|
136
|
-
# Set the user alias based on the full_name.
|
|
137
|
-
if resource.alias.empty?
|
|
138
|
-
resource.update(alias: resource.full_name_initials())
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# new_attributes = resource.detail.attributes.merge({
|
|
142
|
-
# active: resource.active
|
|
143
|
-
# })
|
|
144
|
-
#resource.log_activity_update(current_user, resource, old_attributes, new_attributes)
|
|
145
|
-
else
|
|
146
|
-
self.error(resource.errors.full_messages.to_sentence)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
self
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def sessions
|
|
153
|
-
resource.sessions
|
|
154
|
-
end
|
|
79
|
+
def update(attributes)
|
|
80
|
+
attributes = attributes.to_h.symbolize_keys
|
|
81
|
+
attributes[:time_zone] = attributes[:time_zone].presence if attributes.key?(:time_zone)
|
|
82
|
+
resource.assign_attributes(attributes)
|
|
83
|
+
resource.alias = resource.full_name_initials if resource.alias.blank?
|
|
155
84
|
|
|
156
|
-
|
|
157
|
-
resource
|
|
85
|
+
error(resource.errors.full_messages.to_sentence) unless resource.save
|
|
86
|
+
response(resource)
|
|
158
87
|
end
|
|
159
|
-
|
|
160
|
-
def logs
|
|
161
|
-
return [] unless defined?(LesliAudit)
|
|
162
|
-
resource.logs
|
|
163
|
-
.order(id: :desc)
|
|
164
|
-
.select(:id, :operation, :description, Date2.new.db_column('created_at', as:'date'))
|
|
165
|
-
.limit(7)
|
|
166
|
-
.as_json
|
|
167
|
-
end
|
|
168
88
|
end
|
|
169
89
|
end
|
|
@@ -272,12 +272,9 @@
|
|
|
272
272
|
</div>
|
|
273
273
|
|
|
274
274
|
<nav class="welcome-access" aria-label="Application access">
|
|
275
|
-
<% unless defined?(LesliShield) %>
|
|
276
|
-
<%= link_to("Open applications", "/apps") unless defined?(LesliDashboard) %>
|
|
277
|
-
<% end %>
|
|
278
275
|
<% if defined?(LesliShield) %>
|
|
279
|
-
<%= link_to("
|
|
280
|
-
<%= link_to("
|
|
276
|
+
<%= link_to("Applications", "/lesli/apps") if user_signed_in? %>
|
|
277
|
+
<%= link_to("Dashboard", "/dashboard") if user_signed_in? && defined?(LesliDashboard) %>
|
|
281
278
|
<%= link_to("Log out", "/logout") if user_signed_in? %>
|
|
282
279
|
<%= link_to("Log in", "/login") unless user_signed_in? %>
|
|
283
280
|
<% end %>
|
|
@@ -1,32 +1,18 @@
|
|
|
1
|
-
<style>
|
|
2
|
-
.error-404 .material-symbols {
|
|
3
|
-
font-size: 8rem;
|
|
4
|
-
color: rgb(190,190,190);
|
|
5
|
-
}
|
|
6
|
-
.error-404 h2 {
|
|
7
|
-
font-size: 2rem;
|
|
8
|
-
color: #3d211b;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.error-404 p {
|
|
12
|
-
font-size: 1.4rem;
|
|
13
|
-
font-weight: 300;
|
|
14
|
-
}
|
|
15
|
-
</style>
|
|
16
1
|
<%= render(LesliView::Layout::Container.new("accounts")) do %>
|
|
17
|
-
<section class="
|
|
18
|
-
<div class="
|
|
2
|
+
<section class="px-4 py-24 sm:px-6 sm:py-36" aria-labelledby="not-found-title">
|
|
3
|
+
<div class="mx-auto max-w-2xl text-center">
|
|
19
4
|
|
|
20
|
-
<div class="mb-6">
|
|
5
|
+
<div class="mb-6" aria-hidden="true">
|
|
21
6
|
<%= render(LesliView::Elements::Empty.new(text:nil)) %>
|
|
22
7
|
</div>
|
|
23
8
|
|
|
24
|
-
<h2 class="mb-4
|
|
9
|
+
<h2 id="not-found-title" class="mb-4 text-[2rem] font-semibold leading-tight text-[#3d211b]">
|
|
10
|
+
404 <%= I18n.t("lesli.shared.message_error_not_found") %>
|
|
11
|
+
</h2>
|
|
25
12
|
|
|
26
|
-
<p>
|
|
13
|
+
<p class="text-[1.4rem] font-light leading-relaxed text-neutral-700">
|
|
27
14
|
<%= @message %>
|
|
28
15
|
</p>
|
|
29
16
|
</div>
|
|
30
17
|
</section>
|
|
31
18
|
<% end %>
|
|
32
|
-
|
|
@@ -1,38 +1,23 @@
|
|
|
1
|
-
<style>
|
|
2
|
-
.error-403 .material-symbols {
|
|
3
|
-
font-size: 8rem;
|
|
4
|
-
color: #7a0000;
|
|
5
|
-
}
|
|
6
|
-
.error-403 h2 {
|
|
7
|
-
font-size: 2rem;
|
|
8
|
-
color: #7a0000;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.error-403 p {
|
|
12
|
-
font-size: 1.4rem;
|
|
13
|
-
font-weight: 300;
|
|
14
|
-
}
|
|
15
|
-
</style>
|
|
16
1
|
<%= render(LesliView::Layout::Container.new("accounts")) do %>
|
|
17
|
-
<section class="
|
|
18
|
-
<div class="
|
|
2
|
+
<section class="px-4 py-24 sm:px-6 sm:py-36" aria-labelledby="unauthorized-title">
|
|
3
|
+
<div class="mx-auto max-w-2xl text-center">
|
|
19
4
|
|
|
20
|
-
<div class="mb-6">
|
|
21
|
-
<span class="
|
|
22
|
-
|
|
23
|
-
shield_lock
|
|
24
|
-
</span>
|
|
5
|
+
<div class="mb-6" aria-hidden="true">
|
|
6
|
+
<span class="material-symbols !text-[8rem] leading-none text-danger-800">
|
|
7
|
+
shield_lock
|
|
25
8
|
</span>
|
|
26
9
|
</div>
|
|
27
10
|
|
|
28
|
-
<h2 class="mb-4
|
|
11
|
+
<h2 id="unauthorized-title" class="mb-4 text-[2rem] font-semibold leading-tight text-danger-800">
|
|
12
|
+
403 <%= I18n.t("lesli.shared.message_error_unauthorized") %>
|
|
13
|
+
</h2>
|
|
29
14
|
|
|
30
|
-
<p>
|
|
15
|
+
<p class="text-[1.4rem] font-light leading-relaxed text-neutral-700">
|
|
31
16
|
<%= I18n.t("lesli.shared.message_error_unauthorized_credentials") %>
|
|
32
17
|
</p>
|
|
33
18
|
|
|
34
|
-
<div class="
|
|
35
|
-
<ul>
|
|
19
|
+
<div class="mx-auto mt-6 max-w-xl rounded-lg border border-neutral-200 bg-white p-5 text-sm text-neutral-600 shadow-sm">
|
|
20
|
+
<ul class="space-y-1">
|
|
36
21
|
<li>
|
|
37
22
|
<%= @error_object.dig(:error_details, :controller) %>
|
|
38
23
|
(<%= @error_object.dig(:error_details, :action) %>)
|
|
@@ -43,4 +28,3 @@
|
|
|
43
28
|
</div>
|
|
44
29
|
</section>
|
|
45
30
|
<% end %>
|
|
46
|
-
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Lesli
|
|
4
4
|
|
|
5
|
-
Copyright (c)
|
|
5
|
+
Copyright (c) 2026, 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
|
|
@@ -27,28 +27,29 @@ Building a better future, one line of code at a time.
|
|
|
27
27
|
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
28
28
|
|
|
29
29
|
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
30
|
-
// ·
|
|
30
|
+
// ·
|
|
31
31
|
%>
|
|
32
32
|
|
|
33
|
-
<% public_app_controller = controller_path.split(
|
|
33
|
+
<% public_app_controller = controller_path.split("/")[1] || controller_path %>
|
|
34
34
|
|
|
35
35
|
<!DOCTYPE html>
|
|
36
|
-
<html lang="
|
|
36
|
+
<html lang="<%= I18n.locale %>">
|
|
37
37
|
<head>
|
|
38
38
|
<%= render(partial: "lesli/partials/application-lesli-head") %>
|
|
39
|
-
<%=
|
|
40
|
-
<%= stylesheet_link_tag(lesli_asset_path(:
|
|
41
|
-
|
|
39
|
+
<%= yield :head %>
|
|
40
|
+
<%= stylesheet_link_tag(lesli_asset_path(:lesli_assets, "public"), media: "all") %>
|
|
41
|
+
<%= stylesheet_link_tag(lesli_asset_path(:lesli_shield, public_app_controller), media: "all") %>
|
|
42
|
+
<%# Prevent browser history from reopening an authenticated page after logout. %>
|
|
42
43
|
<% if flash[:logout] == true %>
|
|
43
44
|
<script>
|
|
44
45
|
history.pushState(null, null, null, null, null);
|
|
45
|
-
window.addEventListener(
|
|
46
|
+
window.addEventListener("popstate", function () {
|
|
46
47
|
history.pushState(null, null, null, null, null);
|
|
47
48
|
});
|
|
48
49
|
</script>
|
|
49
50
|
<% end %>
|
|
50
51
|
</head>
|
|
51
|
-
<body class="<%= lesli_application_body_class
|
|
52
|
+
<body class="<%= lesli_application_body_class %>">
|
|
52
53
|
<%= yield %>
|
|
53
54
|
<%= render(partial: "lesli/partials/application-lesli-analytics") %>
|
|
54
55
|
</body>
|
|
@@ -45,8 +45,8 @@ Building a better future, one line of code at a time.
|
|
|
45
45
|
<body class="<%= lesli_application_body_class() %>">
|
|
46
46
|
<%= render(partial: "lesli/partials/application-lesli-header") %>
|
|
47
47
|
<%= render(partial: "lesli/partials/application-lesli-notifications") %>
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
<%= render(partial: "lesli/partials/application-lesli-announcements") %>
|
|
49
|
+
<main class="flex mb-10">
|
|
50
50
|
<%= render(partial: "lesli/partials/application-lesli-content") %>
|
|
51
51
|
</main>
|
|
52
52
|
<div id="lesli-icons" data-turbo-permanent>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<% if @lesli_announcements.present? %>
|
|
2
|
+
<section id="application-lesli-announcements" class="mx-auto mt-6 w-full max-w-7xl space-y-3 px-4 sm:px-6 lg:px-8"
|
|
3
|
+
aria-label="<%= t('lesli.announcements.title') %>">
|
|
4
|
+
<% @lesli_announcements.each do |announcement| %>
|
|
5
|
+
<% style = announcement_style(announcement.category) %>
|
|
6
|
+
<div id="announcement-<%= announcement.id %>"
|
|
7
|
+
class="flex items-center gap-3 rounded-lg border-2 p-4 shadow-sm <%= style.fetch(:classes) %>">
|
|
8
|
+
<span class="material-symbols shrink-0" aria-hidden="true"><%= style.fetch(:icon) %></span>
|
|
9
|
+
<div class="min-w-0 flex-1">
|
|
10
|
+
<span class="sr-only"><%= t("lesli.announcements.categories.#{announcement.category}", default: t('lesli.announcements.categories.info')) %></span>
|
|
11
|
+
<p id="announcement-<%= announcement.id %>-message" class="whitespace-pre-wrap break-words font-medium"><%= announcement.message %></p>
|
|
12
|
+
<% if announcement.url.present? %>
|
|
13
|
+
<%= link_to t('lesli.announcements.open_link'), announcement.url,
|
|
14
|
+
class: "mt-2 inline-block rounded underline underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
15
|
+
data: { turbo_frame: "_top" } %>
|
|
16
|
+
<% end %>
|
|
17
|
+
</div>
|
|
18
|
+
<% if announcement.can_be_closed? %>
|
|
19
|
+
<%= button_to lesli_bell.dismiss_announcement_path(announcement), method: :post,
|
|
20
|
+
class: "inline-flex h-10 w-10 shrink-0 items-center justify-center rounded hover:bg-black/5 focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
21
|
+
aria: { label: t('lesli.announcements.dismiss'), describedby: "announcement-#{announcement.id}-message" } do %>
|
|
22
|
+
<span class="material-symbols" aria-hidden="true">close</span>
|
|
23
|
+
<% end %>
|
|
24
|
+
<% end %>
|
|
25
|
+
</div>
|
|
26
|
+
<% end %>
|
|
27
|
+
</section>
|
|
28
|
+
<% end %>
|
|
@@ -50,9 +50,9 @@ Building a better future, one line of code at a time.
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
<%# Loading stylesheets from engines %>
|
|
53
|
-
<%= stylesheet_link_tag(lesli_asset_path(:lesli_assets, 'application
|
|
54
|
-
<%= stylesheet_link_tag(lesli_asset_path(:
|
|
55
|
-
<%= stylesheet_link_tag(lesli_asset_path(
|
|
53
|
+
<%= stylesheet_link_tag(lesli_asset_path(:lesli_assets, 'application'), media: "all") %>
|
|
54
|
+
<%= stylesheet_link_tag(lesli_asset_path(:lesli_view, 'view'), media: "all") %>
|
|
55
|
+
<%= stylesheet_link_tag(lesli_asset_path(), media: "all") %>
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
<%# Loading javascripts from engines %>
|