pg_rails 7.0.8.pre.alpha.24 → 7.0.8.pre.alpha.25
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 +1 -1
- data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +1 -0
- data/pg_engine/app/controllers/pg_engine/base_controller.rb +23 -0
- data/pg_engine/app/controllers/pg_engine/devise_controller.rb +3 -7
- data/pg_engine/app/controllers/users/registrations_controller.rb +5 -0
- data/pg_engine/app/helpers/pg_engine/i18n_helper.rb +7 -0
- data/pg_engine/app/helpers/pg_engine/pg_rails_helper.rb +0 -4
- data/pg_engine/app/helpers/pg_engine/print_helper.rb +1 -1
- data/pg_engine/app/models/user.rb +1 -1
- data/pg_engine/app/policies/user_policy.rb +3 -15
- data/pg_engine/app/views/pg_engine/base/index.html.slim +10 -1
- data/pg_engine/config/initializers/action_mailer.rb +1 -1
- data/pg_engine/config/locales/es.yml +10 -2
- data/pg_engine/lib/pg_engine/utils/pg_logger.rb +1 -0
- data/pg_engine/spec/controllers/pg_engine/base_controller_spec.rb +52 -0
- data/pg_layout/app/lib/navbar.rb +11 -6
- data/pg_layout/app/views/devise/sessions/new.html.erb +5 -3
- data/pg_layout/app/views/layouts/pg_layout/base.html.slim +2 -2
- data/pg_layout/app/views/pg_layout/_navbar.html.erb +22 -11
- data/pg_layout/app/views/pg_layout/_sidebar.html.erb +1 -1
- data/pg_layout/spec/lib/navbar_spec.rb +32 -0
- data/pg_rails/lib/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ae98a9690f461cc9841e81d2eb82353e5e419db169fa3d7154d97761a1c2496
|
4
|
+
data.tar.gz: 342116ec92cd2f654cf6de83bee8ef4f9e9803ca66daba704e6884f98db06cec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8723ab5cb5ee56dc3e0e14019242a10376d7e804efb8467ba0e19f30273fdee2fb4c8281e077b4d0d9f7bac6e03d5ecdf3e6e39251d1ed31b48e0901f43ac6d
|
7
|
+
data.tar.gz: 62c6b62b972538b2db0df8065c93531b7ed018eaae5818ad9ac8500714bd7907e17451aa2d9e17f9191acd21db258c389eb14ff62411a12cf640fec8078708bd
|
@@ -11,10 +11,32 @@ module PgEngine
|
|
11
11
|
include RouteHelper
|
12
12
|
include PgAssociable::Helpers
|
13
13
|
|
14
|
+
class Redirect < PgEngine::Error
|
15
|
+
attr_accessor :url
|
16
|
+
|
17
|
+
def initialize(url)
|
18
|
+
@url = url
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
14
23
|
protect_from_forgery with: :exception
|
15
24
|
|
16
25
|
rescue_from PrintHelper::FechaInvalidaError, with: :fecha_invalida
|
17
26
|
rescue_from Pundit::NotAuthorizedError, with: :not_authorized
|
27
|
+
rescue_from Redirect do |e|
|
28
|
+
redirect_to e.url
|
29
|
+
end
|
30
|
+
|
31
|
+
helper_method :dev_user_or_env?
|
32
|
+
def dev_user_or_env?
|
33
|
+
Rails.env.development? || dev_user?
|
34
|
+
end
|
35
|
+
|
36
|
+
helper_method :dev_user?
|
37
|
+
def dev_user?
|
38
|
+
current_user&.developer?
|
39
|
+
end
|
18
40
|
|
19
41
|
helper_method :mobile_device?
|
20
42
|
|
@@ -49,6 +71,7 @@ module PgEngine
|
|
49
71
|
# end
|
50
72
|
# end
|
51
73
|
|
74
|
+
# TODO!: ver qué onda esto, tiene sentido acá?
|
52
75
|
def fecha_invalida
|
53
76
|
respond_to do |format|
|
54
77
|
format.json do
|
@@ -2,16 +2,12 @@ module PgEngine
|
|
2
2
|
class DeviseController < ApplicationController
|
3
3
|
before_action :configure_permitted_parameters
|
4
4
|
|
5
|
-
layout :
|
5
|
+
layout :layout_by_user
|
6
6
|
|
7
7
|
protected
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def edit_registration?
|
14
|
-
!(controller_name == 'registrations' && action_name.in?(%w[edit update]))
|
9
|
+
def layout_by_user
|
10
|
+
user_signed_in? ? 'pg_layout/containerized' : 'pg_layout/devise'
|
15
11
|
end
|
16
12
|
|
17
13
|
def configure_permitted_parameters
|
@@ -13,19 +13,7 @@ class UserPolicy < ApplicationPolicy
|
|
13
13
|
# end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# def puede_crear?
|
21
|
-
# acceso_total? || user.asesor?
|
22
|
-
# end
|
23
|
-
|
24
|
-
# def puede_borrar?
|
25
|
-
# acceso_total? && !record.readonly?
|
26
|
-
# end
|
27
|
-
|
28
|
-
# def acceso_total?
|
29
|
-
# user.developer?
|
30
|
-
# end
|
16
|
+
def acceso_total?
|
17
|
+
true
|
18
|
+
end
|
31
19
|
end
|
@@ -48,5 +48,14 @@ div
|
|
48
48
|
|
49
49
|
.ps-3.justify-content-center
|
50
50
|
= paginate(@collection)
|
51
|
+
- elsif @records_filtered
|
52
|
+
- i18n_key = "#{controller_key}.#{action_name}.index.empty_but_filtered"
|
53
|
+
p.m-3
|
54
|
+
= t(i18n_key, default: :'.empty_but_filtered', model: @clase_modelo.nombre_plural.downcase)
|
55
|
+
| :
|
56
|
+
span.ms-2
|
57
|
+
= link_to namespaced_path(@clase_modelo, clean: true) do
|
58
|
+
| Limpiar búsqueda
|
51
59
|
- else
|
52
|
-
|
60
|
+
- i18n_key = "#{controller_key}.#{action_name}.index.empty"
|
61
|
+
p.m-3 = t(i18n_key, default: :'.empty', model: @clase_modelo.nombre_plural.downcase)
|
@@ -1,4 +1,9 @@
|
|
1
1
|
es:
|
2
|
+
pg_engine:
|
3
|
+
base:
|
4
|
+
index:
|
5
|
+
empty: 'No hay %{model} aún'
|
6
|
+
empty_but_filtered: 'No hay %{model} para los filtros aplicados'
|
2
7
|
attributes:
|
3
8
|
created_at: Fecha de creación
|
4
9
|
updated_at: Fecha de actualización
|
@@ -47,6 +52,9 @@ es:
|
|
47
52
|
blank: ''
|
48
53
|
empty: ''
|
49
54
|
devise:
|
55
|
+
sign_in: ¿Ya tenés una cuenta? Iniciar sesión
|
56
|
+
sign_out: Cerrar sesión
|
57
|
+
sign_up: Crear una cuenta
|
50
58
|
registrations:
|
51
59
|
new:
|
52
60
|
sign_up: Crear una cuenta
|
@@ -56,7 +64,7 @@ es:
|
|
56
64
|
forgot_your_password: ¿Olvidaste tu contraseña?
|
57
65
|
shared:
|
58
66
|
links:
|
67
|
+
sign_in: ¿Ya tenés una cuenta? Iniciar sesión
|
59
68
|
sign_up: Crear una cuenta
|
60
69
|
forgot_your_password: ¿Olvidaste tu contraseña?
|
61
|
-
|
62
|
-
didn_t_receive_confirmation_instructions: ¿No recibiste las instrucciones para confirmar tu cuenta?
|
70
|
+
didn_t_receive_confirmation_instructions: ¿No recibiste las instrucciones para confirmar tu cuenta?
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
class DummyBaseController < PgEngine::BaseController
|
4
|
+
def action_with_redirect
|
5
|
+
raise PgEngine::BaseController::Redirect, '/some_path'
|
6
|
+
end
|
7
|
+
|
8
|
+
def check_dev_user
|
9
|
+
@dev_user_or_env = dev_user_or_env?
|
10
|
+
@dev_user = dev_user?
|
11
|
+
head :ok
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# rubocop:disable RSpec/MultipleExpectations
|
16
|
+
# rubocop:disable RSpec/FilePath
|
17
|
+
# rubocop:disable RSpec/SpecFilePathFormat
|
18
|
+
describe DummyBaseController do
|
19
|
+
describe 'PgEngine::BaseController::Redirect' do
|
20
|
+
before { get :action_with_redirect }
|
21
|
+
|
22
|
+
it do
|
23
|
+
expect(response).to redirect_to '/some_path'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#dev_user_or_env?' do
|
28
|
+
let(:user) { create :user, :developer }
|
29
|
+
|
30
|
+
before do
|
31
|
+
sign_in user if user.present?
|
32
|
+
get :check_dev_user
|
33
|
+
end
|
34
|
+
|
35
|
+
it do
|
36
|
+
expect(assigns(:dev_user_or_env)).to be_truthy
|
37
|
+
expect(assigns(:dev_user)).to be_truthy
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when not signed in' do
|
41
|
+
let(:user) { nil }
|
42
|
+
|
43
|
+
it do
|
44
|
+
expect(assigns(:dev_user_or_env)).to be_falsey
|
45
|
+
expect(assigns(:dev_user)).to be_falsey
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
# rubocop:enable RSpec/MultipleExpectations
|
51
|
+
# rubocop:enable RSpec/FilePath
|
52
|
+
# rubocop:enable RSpec/SpecFilePathFormat
|
data/pg_layout/app/lib/navbar.rb
CHANGED
@@ -1,21 +1,26 @@
|
|
1
1
|
class Navbar
|
2
2
|
include Rails.application.routes.url_helpers
|
3
3
|
|
4
|
+
attr_reader :extensiones
|
5
|
+
|
4
6
|
def initialize(user)
|
5
7
|
@user = user
|
8
|
+
@yaml_data = YAML.load_file("#{Rails.application.root}/config/pg_rails.yml")
|
9
|
+
@yaml_data = ActiveSupport::HashWithIndifferentAccess.new(@yaml_data)
|
10
|
+
@extensiones = []
|
6
11
|
end
|
7
12
|
|
8
|
-
def
|
9
|
-
|
13
|
+
def add_html(html)
|
14
|
+
@extensiones << html
|
10
15
|
end
|
11
16
|
|
12
|
-
def
|
13
|
-
|
17
|
+
def add_item(key, obj)
|
18
|
+
@yaml_data[key] ||= []
|
19
|
+
@yaml_data[key] << ActiveSupport::HashWithIndifferentAccess.new(obj)
|
14
20
|
end
|
15
21
|
|
16
22
|
def bar(key)
|
17
|
-
|
18
|
-
bar_data = ActiveSupport::HashWithIndifferentAccess.new(yaml_data)[key]
|
23
|
+
bar_data = @yaml_data[key]
|
19
24
|
return [] if bar_data.blank?
|
20
25
|
|
21
26
|
# rubocop:disable Security/Eval
|
@@ -20,13 +20,15 @@
|
|
20
20
|
|
21
21
|
<%= render "devise/shared/links" %>
|
22
22
|
|
23
|
-
<% if
|
23
|
+
<% if dev_user_or_env? %>
|
24
|
+
<div class="text-end" style="margin-top: 500px">
|
24
25
|
<br>
|
25
26
|
<br>
|
26
27
|
<br>
|
27
|
-
<ul>
|
28
|
-
<% User.
|
28
|
+
<ul style="max-width: 500px">
|
29
|
+
<% User.order(:id).each do |user| %>
|
29
30
|
<li><%= link_to user, admin_login_as_path(id: user.id) %></li>
|
30
31
|
<% end %>
|
31
32
|
</ul>
|
33
|
+
</div>
|
32
34
|
<% end %>
|
@@ -7,7 +7,7 @@ html
|
|
7
7
|
meta name="turbo-cache-control" content="no-cache"
|
8
8
|
/ meta name="turbo-refresh-method" content="morph"
|
9
9
|
/ meta name="turbo-refresh-scroll" content="preserve"
|
10
|
-
|
10
|
+
meta name="turbo-prefetch" content="false"
|
11
11
|
meta name="view-transition" content="same-origin"
|
12
12
|
meta name="cable-history-timestamp" content="#{Time.now.to_i}"
|
13
13
|
= csrf_meta_tags
|
@@ -27,7 +27,7 @@ html
|
|
27
27
|
= render partial: 'pg_layout/flash'
|
28
28
|
= render partial: 'pg_layout/navbar'
|
29
29
|
div
|
30
|
-
- if user_signed_in? &&
|
30
|
+
- if user_signed_in? && breadcrumbs.any?
|
31
31
|
.d-flex.align-items-center.justify-content-between.px-3.py-1.d-print-none[
|
32
32
|
style="min-height: 2.5em;"]
|
33
33
|
nav aria-label="breadcrumb"
|
@@ -11,17 +11,26 @@
|
|
11
11
|
<!-- <span class="navbar-toggler-icon"></span> -->
|
12
12
|
</button>
|
13
13
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
14
|
-
<ul class="navbar-nav
|
14
|
+
<ul class="navbar-nav mb-2 mb-lg-0">
|
15
|
+
<% @navbar.bar('topbar.before').each do |entry| %>
|
16
|
+
<li class="nav-item">
|
17
|
+
<a class="nav-link" href="<%= entry[:path] %>">
|
18
|
+
<%= entry[:title] %>
|
19
|
+
</a>
|
20
|
+
</li>
|
21
|
+
<% end %>
|
15
22
|
<% if user_signed_in? %>
|
16
23
|
<li class="nav-item dropdown">
|
17
24
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
18
25
|
<%= current_user %>
|
19
26
|
</a>
|
20
27
|
<ul class="dropdown-menu">
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
28
|
+
<% if policy(current_user).edit? %>
|
29
|
+
<li>
|
30
|
+
<%= link_to "Mi perfil", edit_user_registration_path, class: 'dropdown-item' %>
|
31
|
+
</li>
|
32
|
+
<% end %>
|
33
|
+
<% @navbar.bar('topbar.dropdown_user').each do |entry| %>
|
25
34
|
<% next if @navbar.hide_entry?(entry) %>
|
26
35
|
<li>
|
27
36
|
<a class="dropdown-item" href="<%= entry[:path] %>">
|
@@ -31,11 +40,12 @@
|
|
31
40
|
<% end %>
|
32
41
|
|
33
42
|
<li>
|
34
|
-
<%= link_to t("devise.
|
43
|
+
<%= link_to t("devise.sign_out"), destroy_user_session_path, data: { 'turbo-method': 'delete' }, class: 'dropdown-item' %>
|
35
44
|
</li>
|
36
45
|
</ul>
|
37
46
|
</li>
|
38
|
-
|
47
|
+
<%# Los item de sidebar en mobile %>
|
48
|
+
<% @navbar.bar('sidebar').each do |entry| %>
|
39
49
|
<% next if @navbar.hide_entry?(entry) %>
|
40
50
|
<% random_id = rand(99999).to_s %>
|
41
51
|
<li class="nav-item d-md-none">
|
@@ -47,15 +57,16 @@
|
|
47
57
|
|
48
58
|
<% else %>
|
49
59
|
<li class="nav-item">
|
50
|
-
<%= link_to t("devise.
|
60
|
+
<%= link_to t("devise.sign_up"), new_user_registration_path, class: 'btn btn-success' %>
|
51
61
|
</li>
|
52
62
|
<li class="nav-item">
|
53
|
-
<%= link_to t("devise.
|
63
|
+
<%= link_to t("devise.sign_in"), new_user_session_path, class: 'nav-link' %>
|
54
64
|
</li>
|
55
65
|
<% end %>
|
56
66
|
</ul>
|
57
|
-
|
58
|
-
|
67
|
+
<% @navbar.extensiones.each do |extension| %>
|
68
|
+
<%= extension %>
|
69
|
+
<% end %>
|
59
70
|
</div>
|
60
71
|
</div>
|
61
72
|
</nav>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
</div> %>
|
14
14
|
<div class="sidebar--large-items">
|
15
15
|
<ul class="list-unstyled ps-0">
|
16
|
-
<% @navbar.sidebar.each do |entry| %>
|
16
|
+
<% @navbar.bar('sidebar').each do |entry| %>
|
17
17
|
<% next if @navbar.hide_entry?(entry) %>
|
18
18
|
<% random_id = rand(99999).to_s %>
|
19
19
|
<li class="mb-1">
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Navbar do
|
4
|
+
let(:user) { create :user }
|
5
|
+
let(:instancia) { described_class.new(user) }
|
6
|
+
|
7
|
+
describe '#add_html' do
|
8
|
+
subject { instancia.add_html(some_html) }
|
9
|
+
|
10
|
+
let(:some_html) { '<p>Hola</p>' }
|
11
|
+
|
12
|
+
it do
|
13
|
+
expect { subject }.to(change(instancia, :extensiones))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#add_item' do
|
18
|
+
subject { instancia.add_item('key', some_item) }
|
19
|
+
|
20
|
+
let(:some_item) do
|
21
|
+
{
|
22
|
+
name: 'Título',
|
23
|
+
path: 'root_path',
|
24
|
+
policy: 'true'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
it do
|
29
|
+
expect { subject }.to(change { instancia.bar('key') })
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
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.25
|
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-04-
|
11
|
+
date: 2024-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rails goodies.
|
14
14
|
email:
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- pg_engine/app/decorators/user_decorator.rb
|
55
55
|
- pg_engine/app/helpers/pg_engine/flash_helper.rb
|
56
56
|
- pg_engine/app/helpers/pg_engine/form_helper.rb
|
57
|
+
- pg_engine/app/helpers/pg_engine/i18n_helper.rb
|
57
58
|
- pg_engine/app/helpers/pg_engine/index_helper.rb
|
58
59
|
- pg_engine/app/helpers/pg_engine/pg_rails_helper.rb
|
59
60
|
- pg_engine/app/helpers/pg_engine/postgres_helper.rb
|
@@ -126,6 +127,7 @@ files:
|
|
126
127
|
- pg_engine/spec/controllers/admin/users_controller_spec.rb
|
127
128
|
- pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
|
128
129
|
- pg_engine/spec/controllers/devise/sessions_controller_spec.rb
|
130
|
+
- pg_engine/spec/controllers/pg_engine/base_controller_spec.rb
|
129
131
|
- pg_engine/spec/controllers/users/confirmations_controller_spec.rb
|
130
132
|
- pg_engine/spec/controllers/users/registrations_controller_spec.rb
|
131
133
|
- pg_engine/spec/factories/accounts.rb
|
@@ -188,6 +190,7 @@ files:
|
|
188
190
|
- pg_layout/app/views/pg_layout/_sidebar.html.erb
|
189
191
|
- pg_layout/lib/pg_layout.rb
|
190
192
|
- pg_layout/lib/pg_layout/engine.rb
|
193
|
+
- pg_layout/spec/lib/navbar_spec.rb
|
191
194
|
- pg_rails/js/index.js
|
192
195
|
- pg_rails/lib/pg_rails.rb
|
193
196
|
- pg_rails/lib/pg_rails/capybara_support.rb
|