pg_rails 7.0.8.pre.alpha.9 → 7.0.8.pre.alpha.10
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/pg_engine/app/controllers/admin/users_controller.rb +16 -4
- data/pg_engine/app/controllers/pg_engine/base_controller.rb +2 -2
- data/pg_engine/app/controllers/pg_engine/devise_controller.rb +16 -3
- data/pg_engine/app/models/pg_engine/base_record.rb +4 -1
- data/pg_engine/app/models/user.rb +7 -4
- data/pg_engine/app/views/pg_engine/base/edit.html.slim +5 -0
- data/pg_engine/app/views/pg_engine/base/new.html.slim +5 -0
- data/pg_engine/config/routes.rb +1 -0
- data/pg_engine/db/migrate/20240305200900_nombre_user.rb +6 -0
- data/pg_engine/db/seeds.rb +1 -1
- data/pg_engine/lib/tasks/auto_anotar_modelos.rake +2 -1
- data/pg_engine/spec/controllers/devise/registrations_controller_spec.rb +33 -0
- data/pg_engine/spec/controllers/devise/sessions_controller_spec.rb +18 -0
- data/pg_engine/spec/factories/users.rb +2 -0
- data/pg_engine/spec/models/pg_engine/base_record_spec.rb +5 -3
- data/pg_layout/app/lib/navbar.rb +13 -3
- data/pg_layout/app/views/devise/registrations/edit.html.erb +2 -0
- data/pg_layout/app/views/devise/registrations/new.html.erb +2 -0
- data/pg_layout/app/views/devise/sessions/new.html.erb +11 -0
- data/pg_layout/app/views/pg_layout/_flash.html.slim +2 -1
- data/pg_layout/app/views/pg_layout/_navbar.html.erb +13 -2
- data/pg_rails/lib/version.rb +1 -1
- data/pg_scaffold/lib/generators/pg_slim/pg_slim_generator.rb +2 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3efd952ef548d103ed1c4aea21b903f039792ed601fc66e93fb5b84dce4d39d
|
4
|
+
data.tar.gz: 148ae25de52ab06846c1b7b313f6f87db0d6d6ba502a9186104559e0e37ec114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68b63352e0ac30ff6f3c7a22e3a2fb73f8918ee91dfefe51b2c8371915c9d7adde99eb114c1ba935387182fa10966d0c5776c672e477486cff17a82993ff68fb
|
7
|
+
data.tar.gz: 1fda6ee9f5416f813e811268f307b87638b69de4a3db4659a7259c6101dc6b8281d9b351e92998e517a0d492cc39eea71780add28b2c240c4971aa26f87a2000
|
@@ -26,22 +26,34 @@ module Admin
|
|
26
26
|
pg_respond_update
|
27
27
|
end
|
28
28
|
|
29
|
+
skip_before_action :authenticate_user!, only: [:login_as]
|
30
|
+
|
31
|
+
# :nocov:
|
32
|
+
def login_as
|
33
|
+
if current_user&.developer? || Rails.env.development?
|
34
|
+
usuario = User.find(params[:id])
|
35
|
+
sign_in(:user, usuario)
|
36
|
+
end
|
37
|
+
redirect_to '/'
|
38
|
+
end
|
39
|
+
# :nocov:
|
40
|
+
|
29
41
|
private
|
30
42
|
|
31
43
|
def atributos_permitidos
|
32
|
-
%i[email password developer]
|
44
|
+
%i[email nombre apellido password developer]
|
33
45
|
end
|
34
46
|
|
35
47
|
def atributos_para_buscar
|
36
|
-
%i[email developer]
|
48
|
+
%i[email nombre apellido developer]
|
37
49
|
end
|
38
50
|
|
39
51
|
def atributos_para_listar
|
40
|
-
%i[email developer]
|
52
|
+
%i[email nombre apellido developer]
|
41
53
|
end
|
42
54
|
|
43
55
|
def atributos_para_mostrar
|
44
|
-
%i[email developer]
|
56
|
+
%i[email nombre apellido developer]
|
45
57
|
end
|
46
58
|
end
|
47
59
|
end
|
@@ -1,9 +1,22 @@
|
|
1
1
|
module PgEngine
|
2
2
|
class DeviseController < ApplicationController
|
3
|
-
|
3
|
+
before_action :configure_permitted_parameters
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
layout :layout_by_resource
|
6
|
+
|
7
|
+
def layout_by_resource
|
8
|
+
if controller_name == 'registrations' && action_name.in?(%w[edit update])
|
9
|
+
'pg_layout/layout'
|
10
|
+
else
|
11
|
+
'pg_layout/devise'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def configure_permitted_parameters
|
18
|
+
devise_parameter_sanitizer.permit(:sign_up, keys: %i[nombre apellido])
|
19
|
+
devise_parameter_sanitizer.permit(:account_update, keys: %i[nombre apellido])
|
7
20
|
end
|
8
21
|
end
|
9
22
|
end
|
@@ -34,9 +34,12 @@ module PgEngine
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.human_attribute_name(attribute, options = {})
|
37
|
-
# Si es un enumerized
|
38
37
|
if attribute.to_s.ends_with?('_text')
|
38
|
+
# Si es un enumerized
|
39
39
|
super(attribute[0..-6], options)
|
40
|
+
elsif attribute.to_s.ends_with?('_f')
|
41
|
+
# Si es un decorated method
|
42
|
+
super(attribute[0..-3], options)
|
40
43
|
else
|
41
44
|
super(attribute, options)
|
42
45
|
end
|
@@ -36,10 +36,9 @@ class User < ApplicationRecord
|
|
36
36
|
# ApplicationRecord should be defined on Application
|
37
37
|
|
38
38
|
# Include default devise modules. Others available are:
|
39
|
-
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
40
39
|
devise :database_authenticatable, :registerable,
|
41
40
|
:recoverable, :rememberable, :validatable,
|
42
|
-
:
|
41
|
+
:lockable, :timeoutable, :trackable, :confirmable
|
43
42
|
|
44
43
|
audited
|
45
44
|
include Discard::Model
|
@@ -47,12 +46,16 @@ class User < ApplicationRecord
|
|
47
46
|
has_many :user_accounts
|
48
47
|
has_many :accounts, through: :user_accounts
|
49
48
|
|
50
|
-
validates :email, presence: true
|
49
|
+
validates :email, :nombre, :apellido, presence: true
|
51
50
|
|
52
51
|
scope :query, ->(param) { where('email ILIKE ?', "%#{param}%") }
|
53
52
|
|
54
53
|
def to_s
|
55
|
-
|
54
|
+
nombre_completo
|
55
|
+
end
|
56
|
+
|
57
|
+
def nombre_completo
|
58
|
+
"#{nombre} #{apellido}"
|
56
59
|
end
|
57
60
|
|
58
61
|
def current_account
|
data/pg_engine/config/routes.rb
CHANGED
data/pg_engine/db/seeds.rb
CHANGED
@@ -3,6 +3,6 @@ DatabaseCleaner.clean_with(:truncation, except: %w(ar_internal_metadata users ac
|
|
3
3
|
MAIL = 'mrosso10@gmail.com'
|
4
4
|
|
5
5
|
unless User.where(email: MAIL).exists?
|
6
|
-
FactoryBot.create :user, email: MAIL, password: 'admin123',
|
6
|
+
FactoryBot.create :user, email: MAIL, nombre: 'Martín', apellido: 'Rosso', password: 'admin123',
|
7
7
|
confirmed_at: Time.now, developer: true
|
8
8
|
end
|
@@ -21,7 +21,8 @@ if Rails.env.development?
|
|
21
21
|
'show_complete_foreign_keys' => 'false',
|
22
22
|
'show_indexes' => 'false',
|
23
23
|
'simple_indexes' => 'true',
|
24
|
-
'model_dir' => 'app/models',
|
24
|
+
'model_dir' => ['app/models', 'app/overrides'],
|
25
|
+
# 'model_dir' => 'app/models',
|
25
26
|
'root_dir' => '',
|
26
27
|
'include_version' => 'false',
|
27
28
|
'require' => '',
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Devise::RegistrationsController do
|
4
|
+
before do
|
5
|
+
# rubocop:disable RSpec/InstanceVariable
|
6
|
+
@request.env['devise.mapping'] = Devise.mappings[:user]
|
7
|
+
# rubocop:enable RSpec/InstanceVariable
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#new' do
|
11
|
+
subject { get :new }
|
12
|
+
|
13
|
+
it do
|
14
|
+
subject
|
15
|
+
expect(response).to have_http_status(:ok)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#edit' do
|
20
|
+
subject { get :edit }
|
21
|
+
|
22
|
+
let(:logger_user) { create :user, :admin }
|
23
|
+
|
24
|
+
before do
|
25
|
+
sign_in logger_user
|
26
|
+
end
|
27
|
+
|
28
|
+
it do
|
29
|
+
subject
|
30
|
+
expect(response).to have_http_status(:ok)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Devise::SessionsController do
|
4
|
+
before do
|
5
|
+
# rubocop:disable RSpec/InstanceVariable
|
6
|
+
@request.env['devise.mapping'] = Devise.mappings[:user]
|
7
|
+
# rubocop:enable RSpec/InstanceVariable
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#new' do
|
11
|
+
subject { get :new }
|
12
|
+
|
13
|
+
it do
|
14
|
+
subject
|
15
|
+
expect(response).to have_http_status(:ok)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -2,12 +2,14 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
describe PgEngine::BaseRecord do
|
4
4
|
describe '#human_attribute_name' do
|
5
|
-
|
6
|
-
described_class.human_attribute_name('bla_text')
|
5
|
+
it do
|
6
|
+
obj = described_class.human_attribute_name('bla_text')
|
7
|
+
expect(obj).to eq described_class.human_attribute_name('bla')
|
7
8
|
end
|
8
9
|
|
9
10
|
it do
|
10
|
-
|
11
|
+
obj = described_class.human_attribute_name('bla_f')
|
12
|
+
expect(obj).to eq described_class.human_attribute_name('bla')
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
data/pg_layout/app/lib/navbar.rb
CHANGED
@@ -5,15 +5,25 @@ class Navbar
|
|
5
5
|
@user = user
|
6
6
|
end
|
7
7
|
|
8
|
+
def topbar
|
9
|
+
bar('topbar')
|
10
|
+
end
|
11
|
+
|
8
12
|
def sidebar
|
13
|
+
bar('sidebar')
|
14
|
+
end
|
15
|
+
|
16
|
+
def bar(key)
|
9
17
|
yaml_data = YAML.load_file("#{Rails.application.root}/config/pg_rails.yml")
|
10
|
-
|
18
|
+
bar_data = ActiveSupport::HashWithIndifferentAccess.new(yaml_data)[key]
|
19
|
+
return [] if bar_data.blank?
|
20
|
+
|
11
21
|
# rubocop:disable Security/Eval
|
12
|
-
|
22
|
+
bar_data.map do |item|
|
13
23
|
{
|
14
24
|
title: item['name'],
|
15
25
|
path: eval(item['path']),
|
16
|
-
show: true
|
26
|
+
show: item['policy'] ? eval(item['policy']) : true
|
17
27
|
}
|
18
28
|
end
|
19
29
|
# rubocop:enable Security/Eval
|
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
<div class="form-inputs">
|
7
7
|
<%= f.input :email, required: true, autofocus: true %>
|
8
|
+
<%= f.input :nombre, required: true %>
|
9
|
+
<%= f.input :apellido, required: true %>
|
8
10
|
|
9
11
|
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
10
12
|
<p><%= t(".currently_waiting_confirmation_for_email", email: resource.unconfirmed_email) %></p>
|
@@ -8,6 +8,8 @@
|
|
8
8
|
required: true,
|
9
9
|
autofocus: true ,
|
10
10
|
input_html: { autocomplete: "email" }%>
|
11
|
+
<%= f.input :nombre, required: true %>
|
12
|
+
<%= f.input :apellido, required: true %>
|
11
13
|
<%= f.input :password,
|
12
14
|
required: true,
|
13
15
|
hint: (t('devise.shared.minimum_password_length', count: @minimum_password_length) if @minimum_password_length),
|
@@ -18,3 +18,14 @@
|
|
18
18
|
<% end %>
|
19
19
|
|
20
20
|
<%= render "devise/shared/links" %>
|
21
|
+
|
22
|
+
<% if Rails.env.development? %>
|
23
|
+
<br>
|
24
|
+
<br>
|
25
|
+
<br>
|
26
|
+
<ul>
|
27
|
+
<% User.all.each do |user| %>
|
28
|
+
<li><%= link_to user, admin_login_as_path(id: user.id) %></li>
|
29
|
+
<% end %>
|
30
|
+
</ul>
|
31
|
+
<% end %>
|
@@ -3,8 +3,9 @@
|
|
3
3
|
- flash_to_show = flash.select { |flash_message| flash_message[0].to_sym.in? ApplicationController._flash_types }
|
4
4
|
/ slim-lint:enable LineLength
|
5
5
|
|
6
|
+
/ TODO: data-turbo-temporary, setear al activar toast?
|
6
7
|
- flash_to_show.each do |flash_type, message|
|
7
8
|
.toast(class="bg-#{flash_type_to_class(flash_type)}-subtle" role="alert" data-bs-autohide="true"
|
8
|
-
data-
|
9
|
+
data-xturbo-temporary="true" aria-live="assertive" aria-atomic="true")
|
9
10
|
.toast-body
|
10
11
|
= message
|
@@ -9,16 +9,25 @@
|
|
9
9
|
<!-- <span class="navbar-toggler-icon"></span> -->
|
10
10
|
</button>
|
11
11
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
12
|
-
<ul class="navbar-nav
|
12
|
+
<ul class="navbar-nav xme-auto mb-2 mb-lg-0">
|
13
13
|
<% if user_signed_in? %>
|
14
14
|
<li class="nav-item dropdown">
|
15
15
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
16
|
-
<%= current_user
|
16
|
+
<%= current_user %>
|
17
17
|
</a>
|
18
18
|
<ul class="dropdown-menu">
|
19
19
|
<li>
|
20
20
|
<%= link_to "Mi perfil", edit_user_registration_path, class: 'dropdown-item' %>
|
21
21
|
</li>
|
22
|
+
<% @navbar.topbar.each do |entry| %>
|
23
|
+
<% next if @navbar.hide_entry?(entry) %>
|
24
|
+
<li>
|
25
|
+
<a class="dropdown-item" href="<%= entry[:path] %>">
|
26
|
+
<%= entry[:title] %>
|
27
|
+
</a>
|
28
|
+
</li>
|
29
|
+
<% end %>
|
30
|
+
|
22
31
|
<li>
|
23
32
|
<%= link_to "Cerrar sesión", destroy_user_session_path, data: { 'turbo-method': 'delete' }, class: 'dropdown-item' %>
|
24
33
|
</li>
|
@@ -40,6 +49,8 @@
|
|
40
49
|
</li>
|
41
50
|
<% end %>
|
42
51
|
</ul>
|
52
|
+
<%= content_for :navbar_ext %>
|
53
|
+
|
43
54
|
</div>
|
44
55
|
</div>
|
45
56
|
</nav>
|
data/pg_rails/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.8.pre.alpha.
|
4
|
+
version: 7.0.8.pre.alpha.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martín Rosso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rails goodies.
|
14
14
|
email:
|
@@ -84,7 +84,9 @@ files:
|
|
84
84
|
- pg_engine/app/views/admin/users/new.html.slim
|
85
85
|
- pg_engine/app/views/admin/users/show.html.slim
|
86
86
|
- pg_engine/app/views/pg_engine/base/download.xlsx.axlsx
|
87
|
+
- pg_engine/app/views/pg_engine/base/edit.html.slim
|
87
88
|
- pg_engine/app/views/pg_engine/base/index.html.slim
|
89
|
+
- pg_engine/app/views/pg_engine/base/new.html.slim
|
88
90
|
- pg_engine/config/initializers/active_admin.rb
|
89
91
|
- pg_engine/config/initializers/devise.rb
|
90
92
|
- pg_engine/config/locales/devise.en.yml
|
@@ -99,6 +101,7 @@ files:
|
|
99
101
|
- pg_engine/db/migrate/20240211152951_create_accounts.rb
|
100
102
|
- pg_engine/db/migrate/20240211153049_create_user_accounts.rb
|
101
103
|
- pg_engine/db/migrate/20240222115722_create_active_storage_tables.active_storage.rb
|
104
|
+
- pg_engine/db/migrate/20240305200900_nombre_user.rb
|
102
105
|
- pg_engine/db/seeds.rb
|
103
106
|
- pg_engine/lib/pg_engine.rb
|
104
107
|
- pg_engine/lib/pg_engine/configuracion.rb
|
@@ -112,6 +115,8 @@ files:
|
|
112
115
|
- pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb
|
113
116
|
- pg_engine/spec/controllers/admin/users_controller_spec.rb
|
114
117
|
- pg_engine/spec/controllers/concerns/pg_engine/error_helper_spec.rb
|
118
|
+
- pg_engine/spec/controllers/devise/registrations_controller_spec.rb
|
119
|
+
- pg_engine/spec/controllers/devise/sessions_controller_spec.rb
|
115
120
|
- pg_engine/spec/factories/accounts.rb
|
116
121
|
- pg_engine/spec/factories/user_accounts.rb
|
117
122
|
- pg_engine/spec/factories/users.rb
|