lesli 5.1.13 → 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/app/controllers/lesli/application_lesli_controller.rb +27 -0
- data/app/controllers/lesli/items/attachments_controller.rb +3 -3
- data/app/controllers/lesli/items/discussions_controller.rb +2 -2
- data/app/controllers/lesli/items/tasks_controller.rb +2 -2
- 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/interfaces/lesli/responder_interface.rb +11 -4
- data/app/models/concerns/lesli/account_initializer.rb +5 -45
- data/app/models/concerns/lesli/user_extensions.rb +4 -2
- data/app/models/lesli/items/attachment.rb +3 -3
- data/app/models/lesli/role.rb +14 -2
- data/app/models/lesli/user.rb +7 -0
- 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/layouts/application-lesli.html.erb +1 -1
- data/app/views/lesli/partials/_application-lesli-announcements.html.erb +28 -0
- data/app/views/lesli/partials/_application-lesli-header.html.erb +3 -2
- data/app/views/lesli/partials/_application-lesli-turbo.html.erb +5 -0
- data/config/initializers/lesli.rb +7 -2
- data/config/locales/translations.en.yml +57 -48
- data/config/locales/translations.es.yml +55 -45
- data/db/migrate/v1/0000000210_create_lesli_users.rb +1 -0
- data/db/seed/xyz.rb +1 -3
- 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/version.rb +2 -2
- data/lib/tasks/lesli/db.rake +16 -93
- data/lib/tasks/lesli/resources.rake +1 -1
- data/readme.md +3 -1
- metadata +24 -3
- data/app/views/lesli/partials/_application-lesli-sidebar.html.erb +0 -50
|
@@ -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
|
|
@@ -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
|
+
<%= render(partial: "lesli/partials/application-lesli-announcements") %>
|
|
48
49
|
<main class="flex mb-10">
|
|
49
|
-
<%= render(partial: "lesli/partials/application-lesli-sidebar") %>
|
|
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 %>
|
|
@@ -40,7 +40,8 @@ Building a better future, one line of code at a time.
|
|
|
40
40
|
|
|
41
41
|
dashboard_label = I18n.t("lesli.header.dashboard", default: "Lesli Dashboard")
|
|
42
42
|
notifications_label = if notifications_count.positive?
|
|
43
|
-
|
|
43
|
+
plural = notifications_count == 1 ? "one" : "other"
|
|
44
|
+
I18n.t("lesli.header.notifications_unread_#{plural}", count: notifications_count, default: "%{count} unread notifications")
|
|
44
45
|
else
|
|
45
46
|
I18n.t("lesli.header.notifications", default: "Notifications")
|
|
46
47
|
end
|
|
@@ -51,7 +52,7 @@ Building a better future, one line of code at a time.
|
|
|
51
52
|
action_class = ->(path) {
|
|
52
53
|
class_names(
|
|
53
54
|
header_action_class,
|
|
54
|
-
current_page?(path) && "
|
|
55
|
+
current_page?(path) && "text-sky-700"
|
|
55
56
|
)
|
|
56
57
|
}
|
|
57
58
|
%>
|
|
@@ -38,4 +38,9 @@ Building a better future, one line of code at a time.
|
|
|
38
38
|
|
|
39
39
|
<%# enable turbo %>
|
|
40
40
|
<meta name="turbo-prefetch" content="false">
|
|
41
|
+
<%# Reload page-specific banners on history navigation instead of restoring
|
|
42
|
+
announcements that another request may have dismissed or expired. %>
|
|
43
|
+
<% if @lesli_announcements_enabled %>
|
|
44
|
+
<meta name="turbo-cache-control" content="no-cache">
|
|
45
|
+
<% end %>
|
|
41
46
|
<meta name="view-transition" content="same-origin" />
|
|
@@ -97,6 +97,7 @@ Lesli.configure do |config|
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
config.babel = {
|
|
100
|
+
allow_web_deploy: true,
|
|
100
101
|
locales: {
|
|
101
102
|
:en => "English", # English
|
|
102
103
|
:es => "Español", # Español/Spanish
|
|
@@ -118,7 +119,11 @@ Lesli.configure do |config|
|
|
|
118
119
|
# Shield module configuration
|
|
119
120
|
config.shield = {
|
|
120
121
|
path_after_login: defined?(LesliDashboard) ? "/dashboard" : "/",
|
|
121
|
-
default_role: "guest"
|
|
122
|
+
default_role: "guest",
|
|
123
|
+
|
|
124
|
+
# Invitations verify ownership of the recipient's email address. The
|
|
125
|
+
# invited user does not exist until the signed link is accepted.
|
|
126
|
+
invitation_expiration: 7.days
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
|
|
@@ -128,8 +133,8 @@ Lesli.configure do |config|
|
|
|
128
133
|
enable_logs: true,
|
|
129
134
|
enable_journals: true,
|
|
130
135
|
enable_analytics: true,
|
|
131
|
-
journal_retention_days: 90,
|
|
132
136
|
analytics_retention_days: 400,
|
|
137
|
+
traffic_retention_days: 400,
|
|
133
138
|
audit_retention_days: nil
|
|
134
139
|
}
|
|
135
140
|
|
|
@@ -1,52 +1,61 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
en:
|
|
3
3
|
lesli:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
add: Add task
|
|
16
|
-
complete_action: Mark task as complete
|
|
17
|
-
completed: Task completed successfully
|
|
18
|
-
created: Task created successfully
|
|
19
|
-
empty: No tasks have been added yet.
|
|
20
|
-
reopen_action: Mark task as incomplete
|
|
21
|
-
reopened: Task reopened successfully
|
|
22
|
-
attachments:
|
|
23
|
-
add: Add file
|
|
24
|
-
category: Category
|
|
25
|
-
choose_file: Choose a file
|
|
26
|
-
created: File uploaded successfully
|
|
27
|
-
deleted: File removed successfully
|
|
28
|
-
download: Download
|
|
29
|
-
empty: No files have been attached yet.
|
|
30
|
-
label: Label
|
|
31
|
-
remove: Remove
|
|
32
|
-
confirm_remove: Remove this file?
|
|
33
|
-
uploading: Uploading...
|
|
34
|
-
errors:
|
|
35
|
-
required: must be attached
|
|
36
|
-
too_large: must be smaller than %{size}
|
|
37
|
-
unsupported_type: has an unsupported file type
|
|
4
|
+
announcements:
|
|
5
|
+
title: "Announcements"
|
|
6
|
+
open_link: "View details"
|
|
7
|
+
dismiss: "Dismiss announcement"
|
|
8
|
+
categories:
|
|
9
|
+
info: "Information"
|
|
10
|
+
success: "Success"
|
|
11
|
+
warning: "Warning"
|
|
12
|
+
danger: "Important notice"
|
|
13
|
+
abouts: {}
|
|
14
|
+
apps: {}
|
|
38
15
|
header:
|
|
39
|
-
applications: Applications
|
|
40
|
-
dashboard: Lesli Dashboard
|
|
41
|
-
logout: Logout
|
|
42
|
-
notifications: Notifications
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
16
|
+
applications: "Applications"
|
|
17
|
+
dashboard: "Lesli Dashboard"
|
|
18
|
+
logout: "Logout"
|
|
19
|
+
notifications: "Notifications"
|
|
20
|
+
notifications_unread_one: "%{count} unread notification"
|
|
21
|
+
notifications_unread_other: "%{count} unread notifications"
|
|
22
|
+
profile: "Profile"
|
|
23
|
+
items:
|
|
24
|
+
activities_empty: "No activities have been recorded yet."
|
|
25
|
+
activities_unknown_actor: "Unknown user"
|
|
26
|
+
attachments_add: "Add file"
|
|
27
|
+
attachments_category: "Category"
|
|
28
|
+
attachments_choose_file: "Choose a file"
|
|
29
|
+
attachments_confirm_remove: "Remove this file?"
|
|
30
|
+
attachments_created: "File uploaded successfully"
|
|
31
|
+
attachments_deleted: "File removed successfully"
|
|
32
|
+
attachments_download: "Download"
|
|
33
|
+
attachments_empty: "No files have been attached yet."
|
|
34
|
+
attachments_errors_required: "must be attached"
|
|
35
|
+
attachments_errors_too_large: "must be smaller than %{size}"
|
|
36
|
+
attachments_errors_unsupported_type: "has an unsupported file type"
|
|
37
|
+
attachments_label: "Label"
|
|
38
|
+
attachments_remove: "Remove"
|
|
39
|
+
attachments_uploading: "Uploading..."
|
|
40
|
+
discussions_add: "Add comment"
|
|
41
|
+
discussions_created: "Comment added successfully"
|
|
42
|
+
discussions_empty: "No comments have been added yet."
|
|
43
|
+
discussions_invalid: "Comment could not be added"
|
|
44
|
+
discussions_unknown_author: "Unknown user"
|
|
45
|
+
tasks_add: "Add task"
|
|
46
|
+
tasks_complete_action: "Mark task as complete"
|
|
47
|
+
tasks_completed: "Task completed successfully"
|
|
48
|
+
tasks_created: "Task created successfully"
|
|
49
|
+
tasks_empty: "No tasks have been added yet."
|
|
50
|
+
tasks_reopen_action: "Mark task as incomplete"
|
|
51
|
+
tasks_reopened: "Task reopened successfully"
|
|
52
|
+
resources: {}
|
|
47
53
|
shared:
|
|
48
|
-
message_error_not_found: Not found
|
|
49
|
-
message_error_resource_not_found: The resource you are looking for was not found.
|
|
50
|
-
message_error_unauthorized: Unauthorized
|
|
51
|
-
message_error_unauthorized_credentials:
|
|
52
|
-
|
|
54
|
+
message_error_not_found: "Not found"
|
|
55
|
+
message_error_resource_not_found: "The resource you are looking for was not found."
|
|
56
|
+
message_error_unauthorized: "Unauthorized"
|
|
57
|
+
message_error_unauthorized_credentials: "We could not validate your privileges. Please ask the administrator to send you an invite to see this content. "
|
|
58
|
+
users/confirmations: {}
|
|
59
|
+
users/passwords: {}
|
|
60
|
+
users/registrations: {}
|
|
61
|
+
users/sessions: {}
|
|
@@ -1,51 +1,61 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
es:
|
|
3
3
|
lesli:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
add: Agregar tarea
|
|
16
|
-
complete_action: Marcar tarea como completada
|
|
17
|
-
completed: Tarea completada exitosamente
|
|
18
|
-
created: Tarea creada exitosamente
|
|
19
|
-
empty: Todavía no se han agregado tareas.
|
|
20
|
-
reopen_action: Marcar tarea como pendiente
|
|
21
|
-
reopened: Tarea reabierta exitosamente
|
|
22
|
-
attachments:
|
|
23
|
-
add: Agregar archivo
|
|
24
|
-
category: Categoría
|
|
25
|
-
choose_file: Seleccionar archivo
|
|
26
|
-
created: Archivo subido exitosamente
|
|
27
|
-
deleted: Archivo eliminado exitosamente
|
|
28
|
-
download: Descargar
|
|
29
|
-
empty: Todavía no se han adjuntado archivos.
|
|
30
|
-
label: Etiqueta
|
|
31
|
-
remove: Eliminar
|
|
32
|
-
confirm_remove: ¿Eliminar este archivo?
|
|
33
|
-
uploading: Subiendo...
|
|
34
|
-
errors:
|
|
35
|
-
required: debe ser adjuntado
|
|
36
|
-
too_large: debe ser menor de %{size}
|
|
37
|
-
unsupported_type: tiene un tipo de archivo no permitido
|
|
4
|
+
announcements:
|
|
5
|
+
title: "Anuncios"
|
|
6
|
+
open_link: "Ver detalles"
|
|
7
|
+
dismiss: "Cerrar anuncio"
|
|
8
|
+
categories:
|
|
9
|
+
info: "Información"
|
|
10
|
+
success: "Éxito"
|
|
11
|
+
warning: "Advertencia"
|
|
12
|
+
danger: "Aviso importante"
|
|
13
|
+
abouts: {}
|
|
14
|
+
apps: {}
|
|
38
15
|
header:
|
|
39
|
-
applications: Aplicaciones
|
|
40
|
-
dashboard: Panel de Lesli
|
|
41
|
-
logout: Cerrar sesión
|
|
42
|
-
notifications: Notificaciones
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
16
|
+
applications: "Aplicaciones"
|
|
17
|
+
dashboard: "Panel de Lesli"
|
|
18
|
+
logout: "Cerrar sesión"
|
|
19
|
+
notifications: "Notificaciones"
|
|
20
|
+
notifications_unread_one: "%{count} notificación sin leer"
|
|
21
|
+
notifications_unread_other: "%{count} notificaciones sin leer"
|
|
22
|
+
profile: "Perfil"
|
|
23
|
+
items:
|
|
24
|
+
activities_empty: "Todavía no se ha registrado actividad."
|
|
25
|
+
activities_unknown_actor: "Usuario desconocido"
|
|
26
|
+
attachments_add: "Agregar archivo"
|
|
27
|
+
attachments_category: "Categoría"
|
|
28
|
+
attachments_choose_file: "Seleccionar archivo"
|
|
29
|
+
attachments_confirm_remove: "¿Eliminar este archivo?"
|
|
30
|
+
attachments_created: "Archivo subido exitosamente"
|
|
31
|
+
attachments_deleted: "Archivo eliminado exitosamente"
|
|
32
|
+
attachments_download: "Descargar"
|
|
33
|
+
attachments_empty: "Todavía no se han adjuntado archivos."
|
|
34
|
+
attachments_errors_required: "debe ser adjuntado"
|
|
35
|
+
attachments_errors_too_large: "debe ser menor de %{size}"
|
|
36
|
+
attachments_errors_unsupported_type: "tiene un tipo de archivo no permitido"
|
|
37
|
+
attachments_label: "Etiqueta"
|
|
38
|
+
attachments_remove: "Eliminar"
|
|
39
|
+
attachments_uploading: "Subiendo..."
|
|
40
|
+
discussions_add: "Agregar comentario"
|
|
41
|
+
discussions_created: "Comentario agregado exitosamente"
|
|
42
|
+
discussions_empty: "Todavía no se han agregado comentarios."
|
|
43
|
+
discussions_invalid: "No se pudo agregar el comentario"
|
|
44
|
+
discussions_unknown_author: "Usuario desconocido"
|
|
45
|
+
tasks_add: "Agregar tarea"
|
|
46
|
+
tasks_complete_action: "Marcar tarea como completada"
|
|
47
|
+
tasks_completed: "Tarea completada exitosamente"
|
|
48
|
+
tasks_created: "Tarea creada exitosamente"
|
|
49
|
+
tasks_empty: "Todavía no se han agregado tareas."
|
|
50
|
+
tasks_reopen_action: "Marcar tarea como pendiente"
|
|
51
|
+
tasks_reopened: "Tarea reabierta exitosamente"
|
|
52
|
+
resources: {}
|
|
47
53
|
shared:
|
|
48
54
|
message_error_not_found: ":lesli.shared.message_error_not_found:"
|
|
49
|
-
message_error_resource_not_found: El recurso que estás buscando no fue encontrado
|
|
50
|
-
message_error_unauthorized: No autorizado
|
|
55
|
+
message_error_resource_not_found: "El recurso que estás buscando no fue encontrado"
|
|
56
|
+
message_error_unauthorized: "No autorizado"
|
|
51
57
|
message_error_unauthorized_credentials: ":lesli.shared.message_error_unauthorized_credentials:"
|
|
58
|
+
users/confirmations: {}
|
|
59
|
+
users/passwords: {}
|
|
60
|
+
users/registrations: {}
|
|
61
|
+
users/sessions: {}
|
data/db/seed/xyz.rb
CHANGED
|
@@ -32,9 +32,7 @@ Building a better future, one line of code at a time.
|
|
|
32
32
|
|
|
33
33
|
def create_account_user(account:, email:, role_name:, first_name:, last_name:, password: nil)
|
|
34
34
|
user = Lesli::User.find_or_initialize_by(email: email)
|
|
35
|
-
authentication_enabled =
|
|
36
|
-
user.respond_to?(:password=) &&
|
|
37
|
-
user.respond_to?(:password_confirmation=)
|
|
35
|
+
authentication_enabled = user.respond_to?(:password=) && user.respond_to?(:password_confirmation=)
|
|
38
36
|
credentials_created = false
|
|
39
37
|
|
|
40
38
|
Lesli::User.transaction do
|
|
@@ -15,9 +15,25 @@ module Lesli
|
|
|
15
15
|
#
|
|
16
16
|
# This avoids duplicating the same helper methods in every generator.
|
|
17
17
|
class BaseGenerator < Rails::Generators::NamedBase
|
|
18
|
+
class_option :engine_root,
|
|
19
|
+
type: :string,
|
|
20
|
+
desc: "Target Rails engine root"
|
|
21
|
+
|
|
22
|
+
class_option :engine_namespace,
|
|
23
|
+
type: :string,
|
|
24
|
+
desc: "Target Rails engine Ruby namespace"
|
|
18
25
|
|
|
19
26
|
private
|
|
20
27
|
|
|
28
|
+
def engine_root
|
|
29
|
+
configured_root = options[:engine_root]
|
|
30
|
+
configured_root = ENGINE_ROOT if configured_root.blank? && defined?(ENGINE_ROOT)
|
|
31
|
+
|
|
32
|
+
raise Thor::Error, "Lesli generators must run inside a Rails engine or receive --engine-root" if configured_root.blank?
|
|
33
|
+
|
|
34
|
+
Pathname.new(configured_root).expand_path
|
|
35
|
+
end
|
|
36
|
+
|
|
21
37
|
# Returns the current engine folder name in snake_case.
|
|
22
38
|
#
|
|
23
39
|
# Examples:
|
|
@@ -25,7 +41,7 @@ module Lesli
|
|
|
25
41
|
# "/code/my_engine" -> "my_engine"
|
|
26
42
|
# "/code/store" -> "store"
|
|
27
43
|
def engine_name
|
|
28
|
-
|
|
44
|
+
engine_root.basename.to_s.underscore
|
|
29
45
|
end
|
|
30
46
|
|
|
31
47
|
# Returns the current engine Ruby namespace in CamelCase.
|
|
@@ -35,7 +51,7 @@ module Lesli
|
|
|
35
51
|
# "my_engine" -> "MyEngine"
|
|
36
52
|
# "store" -> "Store"
|
|
37
53
|
def engine_namespace
|
|
38
|
-
engine_name.camelize
|
|
54
|
+
options[:engine_namespace].presence || engine_name.camelize
|
|
39
55
|
end
|
|
40
56
|
|
|
41
57
|
# Returns the domain name derived from the engine namespace.
|
|
@@ -161,12 +177,34 @@ module Lesli
|
|
|
161
177
|
def permitted_attributes
|
|
162
178
|
return [] unless respond_to?(:attributes)
|
|
163
179
|
|
|
164
|
-
attributes.map(&:
|
|
180
|
+
attributes.map(&:column_name)
|
|
165
181
|
end
|
|
166
182
|
|
|
167
183
|
def namespaced_model_name
|
|
168
184
|
"#{engine_namespace}::#{resource_class_name}"
|
|
169
185
|
end
|
|
186
|
+
|
|
187
|
+
def table_name
|
|
188
|
+
"#{engine_name}_#{resource_collection_name}"
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def account_table_name
|
|
192
|
+
"#{engine_name}_accounts"
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def account_model_path
|
|
196
|
+
engine_root.join("app/models", engine_name, "account.rb")
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def routes_path
|
|
200
|
+
engine_root.join("config/routes.rb")
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def account_resource_scope
|
|
204
|
+
return "current_user.account.#{resource_collection_name}" if engine_namespace == "Lesli"
|
|
205
|
+
|
|
206
|
+
"current_user.account.#{engine_domain_name}.#{resource_collection_name}"
|
|
207
|
+
end
|
|
170
208
|
end
|
|
171
209
|
end
|
|
172
210
|
end
|
|
@@ -25,7 +25,7 @@ module Lesli
|
|
|
25
25
|
# app/controllers/my_engine
|
|
26
26
|
# app/controllers/store
|
|
27
27
|
def controller_directory
|
|
28
|
-
|
|
28
|
+
engine_root.join("app/controllers", engine_name)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Returns the final controller file path.
|
|
@@ -11,7 +11,7 @@ module <%= engine_namespace %>
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def show
|
|
14
|
-
<%= resource_instance %> = <%= resource_instance
|
|
14
|
+
<%= resource_instance %> = <%= resource_instance %>_service.show
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def new
|
|
@@ -40,13 +40,16 @@ module <%= engine_namespace %>
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def update
|
|
43
|
-
|
|
43
|
+
<%= resource_name %> = <%= resource_instance %>_service.update(<%= params_method_name %>)
|
|
44
|
+
<%= resource_instance %> = <%= resource_name %>.result
|
|
45
|
+
|
|
46
|
+
if <%= resource_name %>.successful?
|
|
44
47
|
respond_with_lesli(
|
|
45
48
|
turbo: stream_notification_success("<%= resource_class_name %> updated successfully")
|
|
46
49
|
)
|
|
47
50
|
else
|
|
48
51
|
respond_with_lesli(
|
|
49
|
-
turbo: stream_notification_danger(<%=
|
|
52
|
+
turbo: stream_notification_danger(<%= resource_name %>.errors_as_sentence)
|
|
50
53
|
)
|
|
51
54
|
end
|
|
52
55
|
end
|
|
@@ -55,20 +58,22 @@ module <%= engine_namespace %>
|
|
|
55
58
|
return respond_with_not_found unless <%= resource_instance %>
|
|
56
59
|
return respond_with_unauthorized unless <%= resource_instance %>.is_editable_by?(current_user)
|
|
57
60
|
|
|
58
|
-
<%= resource_name %>_destroy_response = <%=
|
|
61
|
+
<%= resource_name %>_destroy_response = <%= resource_instance %>_service.destroy
|
|
59
62
|
|
|
60
63
|
if <%= resource_name %>_destroy_response.successful?
|
|
61
64
|
respond_with_successful
|
|
62
65
|
else
|
|
63
|
-
respond_with_error(<%= resource_name %>_destroy_response.
|
|
66
|
+
respond_with_error(<%= resource_name %>_destroy_response.errors_as_sentence)
|
|
64
67
|
end
|
|
65
68
|
end
|
|
66
69
|
|
|
67
70
|
private
|
|
68
71
|
|
|
69
72
|
def <%= set_resource_method_name %>
|
|
70
|
-
<%= resource_instance %> = <%= service_class_name %>.new(current_user, query).find(id: params[:id])
|
|
71
|
-
return respond_with_not_found unless <%= resource_instance
|
|
73
|
+
<%= resource_instance %>_service = <%= service_class_name %>.new(current_user, query).find(id: params[:id])
|
|
74
|
+
return respond_with_not_found unless <%= resource_instance %>_service.found?
|
|
75
|
+
|
|
76
|
+
<%= resource_instance %> = <%= resource_instance %>_service.result
|
|
72
77
|
end
|
|
73
78
|
|
|
74
79
|
def <%= params_method_name %>
|