pg_rails 7.6.19 → 7.6.21.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/pg_associable/app/javascript/modal_controller.js +8 -4
  3. data/pg_associable/spec/pg_associable/helpers_spec.rb +8 -13
  4. data/pg_engine/app/components/inline_edit/inline_edit_component.html.slim +1 -1
  5. data/pg_engine/app/components/inline_edit/inline_show_component.html.slim +2 -2
  6. data/pg_engine/app/components/notifications_bell_component.rb +1 -1
  7. data/pg_engine/app/controllers/admin/accounts_controller.rb +2 -2
  8. data/pg_engine/app/controllers/admin/user_accounts_controller.rb +3 -3
  9. data/pg_engine/app/controllers/admin/users_controller.rb +4 -1
  10. data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +12 -7
  11. data/pg_engine/app/controllers/concerns/pg_engine/tenant_helper.rb +33 -0
  12. data/pg_engine/app/controllers/pg_engine/base_admin_controller.rb +0 -1
  13. data/pg_engine/app/controllers/pg_engine/base_controller.rb +18 -21
  14. data/pg_engine/app/controllers/pg_engine/base_public_controller.rb +1 -1
  15. data/pg_engine/app/controllers/pg_engine/base_users_controller.rb +5 -3
  16. data/pg_engine/app/controllers/pg_engine/devise_controller.rb +4 -1
  17. data/pg_engine/app/controllers/pg_engine/tenant_controller.rb +22 -0
  18. data/pg_engine/app/controllers/{users → tenant}/dashboard_controller.rb +2 -2
  19. data/pg_engine/app/controllers/tenant/inline_edit_controller.rb +22 -0
  20. data/pg_engine/app/controllers/tenant/user_accounts_controller.rb +56 -0
  21. data/pg_engine/app/controllers/users/accounts_controller.rb +46 -15
  22. data/pg_engine/app/controllers/users/invitations_controller.rb +78 -0
  23. data/pg_engine/app/controllers/users/notifications_controller.rb +1 -0
  24. data/pg_engine/app/controllers/users/registrations_controller.rb +3 -2
  25. data/pg_engine/app/decorators/account_decorator.rb +18 -0
  26. data/pg_engine/app/decorators/pg_engine/base_record_decorator.rb +9 -1
  27. data/pg_engine/app/decorators/user_account_decorator.rb +76 -11
  28. data/pg_engine/app/helpers/pg_engine/accounts_helper.rb +9 -0
  29. data/pg_engine/app/helpers/pg_engine/frame_helper.rb +12 -0
  30. data/pg_engine/app/lib/pg_engine/default_url_options.rb +21 -0
  31. data/pg_engine/app/lib/pg_engine/filtros_builder.rb +2 -0
  32. data/pg_engine/app/models/account.rb +28 -1
  33. data/pg_engine/app/models/concerns/pg_engine/child_record.rb +55 -0
  34. data/pg_engine/app/models/current.rb +21 -3
  35. data/pg_engine/app/models/pg_engine/base_record.rb +5 -0
  36. data/pg_engine/app/models/user.rb +51 -9
  37. data/pg_engine/app/models/user_account.rb +74 -9
  38. data/pg_engine/app/policies/account_policy.rb +35 -16
  39. data/pg_engine/app/policies/email_log_policy.rb +0 -4
  40. data/pg_engine/app/policies/email_policy.rb +0 -4
  41. data/pg_engine/app/policies/pg_engine/base_policy.rb +31 -10
  42. data/pg_engine/app/policies/user_account_policy.rb +59 -25
  43. data/pg_engine/app/policies/user_policy.rb +14 -1
  44. data/pg_engine/app/views/admin/user_accounts/_form.html.slim +1 -1
  45. data/pg_engine/app/views/admin/user_accounts/show.html.slim +15 -0
  46. data/pg_engine/app/views/admin/users/show.html.slim +0 -3
  47. data/pg_engine/app/views/pg_engine/base/index.html.slim +2 -2
  48. data/pg_engine/app/views/tenant/dashboard/dashboard.html.slim +2 -0
  49. data/pg_engine/app/views/tenant/user_accounts/_fields.html.slim +13 -0
  50. data/pg_engine/app/views/tenant/user_accounts/_form.html.slim +9 -0
  51. data/pg_engine/app/views/tenant/user_accounts/show.html.slim +20 -0
  52. data/pg_engine/app/views/users/accounts/_form.html.slim +7 -0
  53. data/pg_engine/app/views/users/accounts/show.html.slim +23 -15
  54. data/pg_engine/config/initializers/acts_as_tenant.rb +7 -2
  55. data/pg_engine/config/initializers/devise.rb +10 -0
  56. data/pg_engine/config/initializers/ransack.rb +2 -0
  57. data/pg_engine/config/locales/es.yml +60 -0
  58. data/pg_engine/config/routes.rb +21 -11
  59. data/pg_engine/config/simple_form/simple_form_bootstrap.rb +2 -2
  60. data/pg_engine/db/migrate/20241023203849_devise_invitable.rb +14 -0
  61. data/pg_engine/db/migrate/20241027225618_add_membership_status_to_user_accounts.rb +6 -0
  62. data/pg_engine/db/seeds.rb +6 -6
  63. data/pg_engine/lib/pg_engine/configuracion.rb +36 -1
  64. data/pg_engine/lib/pg_engine/navigator.rb +2 -25
  65. data/pg_engine/lib/pg_engine/utils/{check_invalid_records.rb → resource_reports.rb} +22 -3
  66. data/pg_engine/lib/pg_engine.rb +1 -0
  67. data/pg_engine/spec/controllers/admin/accounts_controller_spec.rb +3 -2
  68. data/pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb +11 -9
  69. data/pg_engine/spec/factories/accounts.rb +8 -0
  70. data/pg_engine/spec/factories/user_accounts.rb +1 -1
  71. data/pg_engine/spec/factories/users.rb +6 -0
  72. data/pg_engine/spec/models/concerns/pg_engine/child_record_spec.rb +27 -0
  73. data/pg_engine/spec/models/user_account_spec.rb +5 -1
  74. data/pg_engine/spec/models/user_spec.rb +3 -25
  75. data/pg_engine/spec/policies/account_policy_spec.rb +19 -0
  76. data/pg_engine/spec/requests/devise/invitations_spec.rb +196 -0
  77. data/pg_engine/spec/requests/resource_spec.rb +14 -15
  78. data/pg_engine/spec/requests/users/accounts_spec.rb +117 -8
  79. data/pg_engine/spec/requests/users/base_controller_spec.rb +31 -0
  80. data/pg_engine/spec/requests/users/dashboard_spec.rb +4 -9
  81. data/pg_engine/spec/requests/users/date_jumper_spec.rb +2 -1
  82. data/pg_engine/spec/requests/users/inline_edit_spec.rb +6 -5
  83. data/pg_engine/spec/requests/users/registrations_spec.rb +2 -2
  84. data/pg_engine/spec/requests/users/user_accounts_spec.rb +54 -0
  85. data/pg_engine/spec/system/login_spec.rb +2 -2
  86. data/pg_engine/spec/system/noticed_spec.rb +0 -2
  87. data/pg_engine/spec/system/signup_spec.rb +4 -3
  88. data/pg_engine/spec/system/tenants_spec.rb +10 -9
  89. data/pg_layout/app/javascript/application.js +1 -1
  90. data/pg_layout/app/javascript/config/turbo_rails/index.js +1 -1
  91. data/pg_layout/app/lib/navbar.rb +15 -1
  92. data/pg_layout/app/views/devise/invitations/edit.html.erb +34 -0
  93. data/pg_layout/app/views/devise/invitations/new.html.erb +15 -0
  94. data/pg_layout/app/views/devise/mailer/invitation_instructions.html.erb +11 -0
  95. data/pg_layout/app/views/devise/mailer/invitation_instructions.text.erb +11 -0
  96. data/pg_layout/app/views/devise/registrations/edit.html.erb +1 -0
  97. data/pg_layout/app/views/layouts/pg_layout/base.html.slim +6 -5
  98. data/pg_layout/app/views/pg_layout/_navbar.html.erb +7 -6
  99. data/pg_layout/app/views/pg_layout/_sidebar.html.erb +2 -20
  100. data/pg_layout/app/views/pg_layout/_signed_in_links.html.slim +52 -0
  101. data/pg_layout/lib/pg_layout.rb +0 -5
  102. data/pg_rails/lib/pg_rails/pundit_matchers.rb +21 -0
  103. data/pg_rails/lib/pg_rails/tpath_support.rb +73 -0
  104. data/pg_rails/lib/pg_rails.rb +6 -0
  105. data/pg_rails/lib/version.rb +1 -1
  106. data/pg_rails/scss/pg_rails.scss +1 -1
  107. data/pg_scaffold/lib/generators/pg_rspec/scaffold/templates/controller_spec.rb +1 -1
  108. data/pg_scaffold/lib/generators/pg_slim/templates/index.html.slim +1 -1
  109. metadata +44 -10
  110. data/pg_engine/app/controllers/concerns/pg_engine/require_tenant_set.rb +0 -15
  111. data/pg_engine/app/controllers/users/account_switcher_controller.rb +0 -30
  112. data/pg_engine/app/controllers/users/inline_edit_controller.rb +0 -21
  113. data/pg_engine/app/views/users/account_switcher/list.html.slim +0 -24
  114. data/pg_engine/app/views/users/dashboard/dashboard.html.slim +0 -1
  115. data/pg_engine/spec/requests/users/switcher_spec.rb +0 -84
@@ -0,0 +1,52 @@
1
+ - if user_signed_in?
2
+ .xcollapse.xnavbar-collapse.justify-content-end
3
+ ul.navbar-nav.flex-row
4
+ - if Current.account.present?
5
+ li.nav-item.dropdown
6
+ = link_to '#', class: 'nav-link dropdown-toggle py-0 d-flex align-items-center',
7
+ role: :button, 'data-bs-toggle': :dropdown, 'aria-expanded': 'false' do
8
+ - if Current.account.logo.present?
9
+ = image_tag Current.account.logo.variant(:thumb), class: 'rounded-circle border border-2 me-2', width: 40, height: 40
10
+ - else
11
+ i.bi.bi-bag-fill.me-2 style="font-size: 1.7em"
12
+ = Current.account
13
+ ul.dropdown-menu
14
+ - if @other_active_accounts&.any?
15
+ h6.dropdown-header Cambiar a:
16
+ - @other_active_accounts.each do |ua|
17
+ li = link_to ua.account, tenant_root_path(tid: ua.to_param), class: 'dropdown-item'
18
+ li
19
+ hr.dropdown-divider
20
+ li = link_to "Administrar #{Account.model_name.human(count: 2)}", users_accounts_path(tid: nil), class: 'dropdown-item'
21
+ - elsif @other_active_accounts&.any?
22
+ li.nav-item.dropdown.d-flex
23
+ = link_to '#', class: 'nav-link dropdown-toggle py-0 d-flex align-items-center',
24
+ role: :button, 'data-bs-toggle': :dropdown, 'aria-expanded': 'false' do
25
+ i.bi.bi-bag-fill.me-2 style="font-size: 1.7em"
26
+ = Account.model_name.human(count: 2)
27
+ ul.dropdown-menu
28
+ - @other_active_accounts.each do |ua|
29
+ li = link_to ua.account, tenant_root_path(tid: ua.to_param), class: 'dropdown-item'
30
+ li
31
+ hr.dropdown-divider
32
+ li = link_to "Administrar #{Account.model_name.human(count: 2).downcase}", users_accounts_path(tid: nil), class: 'dropdown-item'
33
+
34
+ .vr.bg-white.mx-3
35
+ - if Current.user.present? && @notifications_bell.present?
36
+ = render @notifications_bell
37
+ .vr.bg-white.mx-3
38
+ li.nav-item.dropdown.me-3
39
+ = link_to '#', class: 'nav-link dropdown-toggle py-0 d-flex align-items-center',
40
+ role: :button, 'data-bs-toggle': :dropdown, 'aria-expanded': 'false' do
41
+ - if Current.user.avatar.present?
42
+ = image_tag Current.user.avatar.variant(:thumb), class: 'rounded-circle border border-2 me-2', width: 40, height: 40
43
+ - else
44
+ i.bi.bi-person-circle.me-2 style="font-size: 1.7em"
45
+ = Current.user
46
+ ul.dropdown-menu
47
+ li = link_to 'Perfil', edit_user_registration_path(tid: nil), class: 'dropdown-item'
48
+ li = link_to Account.model_name.human(count: 2), users_accounts_path(tid: nil), class: 'dropdown-item'
49
+ - if Current.user.developer?
50
+ li = link_to 'Admin', admin_users_path, class: 'dropdown-item'
51
+ li = link_to 'Cerrar sesión', destroy_user_session_path(tid: nil),
52
+ 'data-turbo-method': :delete, class: 'dropdown-item'
@@ -1,8 +1,3 @@
1
- # Para que la viewpath de pg_layout tenga precedencia sobre las de kaminari y devise
2
- require 'kaminari'
3
- require 'devise'
4
- require 'devise-i18n'
5
-
6
1
  require_relative 'pg_layout/engine'
7
2
 
8
3
  module PgLayout
@@ -0,0 +1,21 @@
1
+ # :nocov:
2
+ RSpec::Matchers.define :permit do |action|
3
+ match do |policy|
4
+ policy.public_send("#{action}?")
5
+ end
6
+
7
+ failure_message do |policy|
8
+ <<~STRING
9
+ #{policy.class} does not permit #{action}
10
+ on #{policy.record} for #{policy.user.inspect}.
11
+ STRING
12
+ end
13
+
14
+ failure_message_when_negated do |policy|
15
+ <<~STRING
16
+ #{policy.class} does not forbid #{action} on
17
+ #{policy.record} for #{policy.user.inspect}.
18
+ STRING
19
+ end
20
+ end
21
+ # :nocov:
@@ -0,0 +1,73 @@
1
+ # :nocov:
2
+ module PgEngine
3
+ module TpathSupport
4
+ module RequestsPatch
5
+ def get(url, **)
6
+ super(tpath(url), **)
7
+ end
8
+
9
+ def post(url, **)
10
+ super(tpath(url), **)
11
+ end
12
+
13
+ def put(url, **)
14
+ super(tpath(url), **)
15
+ end
16
+
17
+ def patch(url, **)
18
+ super(tpath(url), **)
19
+ end
20
+
21
+ def delete(url, **)
22
+ super(tpath(url), **)
23
+ end
24
+
25
+ def redirect_to(arg, tpath: true)
26
+ if tpath
27
+ super(tpath(arg, query_string: false))
28
+ else
29
+ super(arg)
30
+ end
31
+ end
32
+ end
33
+
34
+ module ControllersPatch
35
+ def redirect_to(arg, tpath: true)
36
+ if tpath
37
+ super(tpath(arg, query_string: false))
38
+ else
39
+ super(arg)
40
+ end
41
+ end
42
+ end
43
+
44
+ def _tpath_ua
45
+ usr = if respond_to?(:logged_user)
46
+ logged_user
47
+ elsif respond_to?(:user)
48
+ user
49
+ else
50
+ raise 'no user available'
51
+ end
52
+
53
+ raise 'user is null' if usr.nil?
54
+
55
+ usr.active_user_account_for(ActsAsTenant.current_tenant)
56
+ end
57
+
58
+ def tpath(arg, query_string: true)
59
+ ua = _tpath_ua
60
+ return arg.push(tid: ua.to_param) if arg.is_a? Array
61
+
62
+ path = arg
63
+
64
+ if query_string
65
+ "#{path}?tid=#{ua.to_param}"
66
+ else
67
+ # "/u/t/#{ua.to_param}#{path}"
68
+ path.sub('/u/t/', "/u/t/#{ua.to_param}/")
69
+ end
70
+ end
71
+ end
72
+ end
73
+ # :nocov:
@@ -1,3 +1,9 @@
1
+ # Para que la viewpath y localepath de pg_rails tengan precedencia sobre las de kaminari y devise
2
+ require 'kaminari'
3
+ require 'devise'
4
+ require 'devise-i18n'
5
+ require 'devise_invitable'
6
+
1
7
  require "#{__dir__}/../../pg_engine/lib/pg_engine"
2
8
  require "#{__dir__}/../../pg_associable/lib/pg_associable"
3
9
  require "#{__dir__}/../../pg_scaffold/lib/pg_scaffold" if Rails.env.local?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.6.19'
4
+ VERSION = '7.6.21.pre.1'
5
5
  end
@@ -77,7 +77,7 @@ $values: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100;
77
77
  white-space: nowrap;
78
78
  min-width: 30em * $value * 0.01;
79
79
 
80
- // FIXME: con css grid esto se debería poder hacer mejor
80
+ // TODO: con css grid esto se debería poder hacer mejor
81
81
  // además, el pg_asociable directamente se rompe
82
82
  &:has(form) {
83
83
  min-width: 28em;
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # FIXME: reemplazar por requests spec
3
+ # TODO: reemplazar por requests spec
4
4
  # generado con pg_rails
5
5
 
6
6
  require 'rails_helper'
@@ -9,7 +9,7 @@
9
9
  = @clase_modelo.new.decorate.new_link
10
10
  .ms-1
11
11
  = @clase_modelo.new.decorate.export_link(request.url)
12
- / FIXME: update
12
+ / TODO: update
13
13
  .collapse.p-2.border-bottom#filtros class="#{ 'show' if show_filters? }"
14
14
  .d-flex.align-items-center
15
15
  .px-2.d-none.d-sm-inline-block
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.6.19
4
+ version: 7.6.21.pre.1
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-10-18 00:00:00.000000000 Z
11
+ date: 2024-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -206,6 +206,20 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: 1.12.0
209
+ - !ruby/object:Gem::Dependency
210
+ name: devise_invitable
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: 2.0.9
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: 2.0.9
209
223
  - !ruby/object:Gem::Dependency
210
224
  name: rails-i18n
211
225
  requirement: !ruby/object:Gem::Requirement
@@ -695,8 +709,8 @@ files:
695
709
  - pg_engine/app/controllers/admin/simple_user_notifiers_controller.rb
696
710
  - pg_engine/app/controllers/admin/user_accounts_controller.rb
697
711
  - pg_engine/app/controllers/admin/users_controller.rb
698
- - pg_engine/app/controllers/concerns/pg_engine/require_tenant_set.rb
699
712
  - pg_engine/app/controllers/concerns/pg_engine/resource.rb
713
+ - pg_engine/app/controllers/concerns/pg_engine/tenant_helper.rb
700
714
  - pg_engine/app/controllers/pg_engine/base_admin_controller.rb
701
715
  - pg_engine/app/controllers/pg_engine/base_controller.rb
702
716
  - pg_engine/app/controllers/pg_engine/base_public_controller.rb
@@ -704,14 +718,16 @@ files:
704
718
  - pg_engine/app/controllers/pg_engine/devise_controller.rb
705
719
  - pg_engine/app/controllers/pg_engine/health_controller.rb
706
720
  - pg_engine/app/controllers/pg_engine/require_sign_in.rb
721
+ - pg_engine/app/controllers/pg_engine/tenant_controller.rb
707
722
  - pg_engine/app/controllers/public/mensaje_contactos_controller.rb
708
723
  - pg_engine/app/controllers/public/webhooks_controller.rb
709
- - pg_engine/app/controllers/users/account_switcher_controller.rb
724
+ - pg_engine/app/controllers/tenant/dashboard_controller.rb
725
+ - pg_engine/app/controllers/tenant/inline_edit_controller.rb
726
+ - pg_engine/app/controllers/tenant/user_accounts_controller.rb
710
727
  - pg_engine/app/controllers/users/accounts_controller.rb
711
728
  - pg_engine/app/controllers/users/confirmations_controller.rb
712
- - pg_engine/app/controllers/users/dashboard_controller.rb
713
729
  - pg_engine/app/controllers/users/date_jumper_controller.rb
714
- - pg_engine/app/controllers/users/inline_edit_controller.rb
730
+ - pg_engine/app/controllers/users/invitations_controller.rb
715
731
  - pg_engine/app/controllers/users/notifications_controller.rb
716
732
  - pg_engine/app/controllers/users/registrations_controller.rb
717
733
  - pg_engine/app/decorators/account_decorator.rb
@@ -722,6 +738,7 @@ files:
722
738
  - pg_engine/app/decorators/pg_engine/base_record_decorator.rb
723
739
  - pg_engine/app/decorators/user_account_decorator.rb
724
740
  - pg_engine/app/decorators/user_decorator.rb
741
+ - pg_engine/app/helpers/pg_engine/accounts_helper.rb
725
742
  - pg_engine/app/helpers/pg_engine/flash_helper.rb
726
743
  - pg_engine/app/helpers/pg_engine/form_helper.rb
727
744
  - pg_engine/app/helpers/pg_engine/frame_helper.rb
@@ -734,6 +751,7 @@ files:
734
751
  - pg_engine/app/inputs/pg_engine/fecha_input.rb
735
752
  - pg_engine/app/lib/pg_engine/bootstrap5_breadcrumbs_builder.rb
736
753
  - pg_engine/app/lib/pg_engine/date_jumper.rb
754
+ - pg_engine/app/lib/pg_engine/default_url_options.rb
737
755
  - pg_engine/app/lib/pg_engine/devise_failure_app.rb
738
756
  - pg_engine/app/lib/pg_engine/error_helper.rb
739
757
  - pg_engine/app/lib/pg_engine/filtros_builder.rb
@@ -742,6 +760,7 @@ files:
742
760
  - pg_engine/app/mailers/pg_engine/base_mailer.rb
743
761
  - pg_engine/app/mailers/pg_engine/user_mailer.rb
744
762
  - pg_engine/app/models/account.rb
763
+ - pg_engine/app/models/concerns/pg_engine/child_record.rb
745
764
  - pg_engine/app/models/concerns/pg_engine/naming.rb
746
765
  - pg_engine/app/models/current.rb
747
766
  - pg_engine/app/models/email.rb
@@ -797,9 +816,12 @@ files:
797
816
  - pg_engine/app/views/pg_engine/user_mailer/notification.text.slim
798
817
  - pg_engine/app/views/public/mensaje_contactos/_gracias.html.slim
799
818
  - pg_engine/app/views/public/mensaje_contactos/new.html.slim
800
- - pg_engine/app/views/users/account_switcher/list.html.slim
819
+ - pg_engine/app/views/tenant/dashboard/dashboard.html.slim
820
+ - pg_engine/app/views/tenant/user_accounts/_fields.html.slim
821
+ - pg_engine/app/views/tenant/user_accounts/_form.html.slim
822
+ - pg_engine/app/views/tenant/user_accounts/show.html.slim
823
+ - pg_engine/app/views/users/accounts/_form.html.slim
801
824
  - pg_engine/app/views/users/accounts/show.html.slim
802
- - pg_engine/app/views/users/dashboard/dashboard.html.slim
803
825
  - pg_engine/config/initializers/action_controller.rb
804
826
  - pg_engine/config/initializers/action_mailer.rb
805
827
  - pg_engine/config/initializers/active_admin.rb
@@ -837,6 +859,8 @@ files:
837
859
  - pg_engine/db/migrate/20240611000220_add_notifications_count_to_noticed_event.noticed.rb
838
860
  - pg_engine/db/migrate/20240614130246_create_action_text_tables.action_text.rb
839
861
  - pg_engine/db/migrate/20240905154330_account_tenant_columns.rb
862
+ - pg_engine/db/migrate/20241023203849_devise_invitable.rb
863
+ - pg_engine/db/migrate/20241027225618_add_membership_status_to_user_accounts.rb
840
864
  - pg_engine/db/seeds.rb
841
865
  - pg_engine/lib/pg_engine.rb
842
866
  - pg_engine/lib/pg_engine/configuracion.rb
@@ -847,9 +871,9 @@ files:
847
871
  - pg_engine/lib/pg_engine/mailgun/log_sync.rb
848
872
  - pg_engine/lib/pg_engine/navigator.rb
849
873
  - pg_engine/lib/pg_engine/route_helpers.rb
850
- - pg_engine/lib/pg_engine/utils/check_invalid_records.rb
851
874
  - pg_engine/lib/pg_engine/utils/pdf_preview_generator.rb
852
875
  - pg_engine/lib/pg_engine/utils/pg_logger.rb
876
+ - pg_engine/lib/pg_engine/utils/resource_reports.rb
853
877
  - pg_engine/lib/tasks/auto_anotar_modelos.rake
854
878
  - pg_engine/spec/components/alert_component_spec.rb
855
879
  - pg_engine/spec/components/internal_error_component_spec.rb
@@ -890,6 +914,7 @@ files:
890
914
  - pg_engine/spec/lib/pg_form_builder_spec.rb
891
915
  - pg_engine/spec/mailers/previews/devise_preview.rb
892
916
  - pg_engine/spec/models/account_spec.rb
917
+ - pg_engine/spec/models/concerns/pg_engine/child_record_spec.rb
893
918
  - pg_engine/spec/models/email_log_spec.rb
894
919
  - pg_engine/spec/models/email_spec.rb
895
920
  - pg_engine/spec/models/mensaje_contacto_spec.rb
@@ -898,10 +923,12 @@ files:
898
923
  - pg_engine/spec/models/user_spec.rb
899
924
  - pg_engine/spec/overrides/audited_audit_spec.rb
900
925
  - pg_engine/spec/pg_engine/pdf_preview_generator_spec.rb
926
+ - pg_engine/spec/policies/account_policy_spec.rb
901
927
  - pg_engine/spec/requests/active_storage_spec.rb
902
928
  - pg_engine/spec/requests/admin/eventos_spec.rb
903
929
  - pg_engine/spec/requests/base_controller_requests_spec.rb
904
930
  - pg_engine/spec/requests/current_attributes_spec.rb
931
+ - pg_engine/spec/requests/devise/invitations_spec.rb
905
932
  - pg_engine/spec/requests/devise_spec.rb
906
933
  - pg_engine/spec/requests/public/webhooks_spec.rb
907
934
  - pg_engine/spec/requests/resource_spec.rb
@@ -911,7 +938,7 @@ files:
911
938
  - pg_engine/spec/requests/users/date_jumper_spec.rb
912
939
  - pg_engine/spec/requests/users/inline_edit_spec.rb
913
940
  - pg_engine/spec/requests/users/registrations_spec.rb
914
- - pg_engine/spec/requests/users/switcher_spec.rb
941
+ - pg_engine/spec/requests/users/user_accounts_spec.rb
915
942
  - pg_engine/spec/system/alerts_spec.rb
916
943
  - pg_engine/spec/system/breadcrumbs_spec.rb
917
944
  - pg_engine/spec/system/date_selector_spec.rb
@@ -960,8 +987,12 @@ files:
960
987
  - pg_layout/app/javascript/utils/utils.ts
961
988
  - pg_layout/app/lib/navbar.rb
962
989
  - pg_layout/app/views/devise/confirmations/new.html.erb
990
+ - pg_layout/app/views/devise/invitations/edit.html.erb
991
+ - pg_layout/app/views/devise/invitations/new.html.erb
963
992
  - pg_layout/app/views/devise/mailer/confirmation_instructions.html.erb
964
993
  - pg_layout/app/views/devise/mailer/email_changed.html.erb
994
+ - pg_layout/app/views/devise/mailer/invitation_instructions.html.erb
995
+ - pg_layout/app/views/devise/mailer/invitation_instructions.text.erb
965
996
  - pg_layout/app/views/devise/mailer/password_change.html.erb
966
997
  - pg_layout/app/views/devise/mailer/reset_password_instructions.html.erb
967
998
  - pg_layout/app/views/devise/mailer/unlock_instructions.html.erb
@@ -993,6 +1024,7 @@ files:
993
1024
  - pg_layout/app/views/pg_layout/_navbar.html.erb
994
1025
  - pg_layout/app/views/pg_layout/_sidebar.html.erb
995
1026
  - pg_layout/app/views/pg_layout/_sidebar_mobile.html.erb
1027
+ - pg_layout/app/views/pg_layout/_signed_in_links.html.slim
996
1028
  - pg_layout/lib/pg_layout.rb
997
1029
  - pg_layout/lib/pg_layout/engine.rb
998
1030
  - pg_layout/spec/lib/navbar_spec.rb
@@ -1001,9 +1033,11 @@ files:
1001
1033
  - pg_rails/lib/pg_rails/capybara_support.rb
1002
1034
  - pg_rails/lib/pg_rails/current_attributes_support.rb
1003
1035
  - pg_rails/lib/pg_rails/dotenv_support.rb
1036
+ - pg_rails/lib/pg_rails/pundit_matchers.rb
1004
1037
  - pg_rails/lib/pg_rails/redis_support.rb
1005
1038
  - pg_rails/lib/pg_rails/rspec_logger_matchers.rb
1006
1039
  - pg_rails/lib/pg_rails/tom_select_helpers.rb
1040
+ - pg_rails/lib/pg_rails/tpath_support.rb
1007
1041
  - pg_rails/lib/pg_rails/vcr_support.rb
1008
1042
  - pg_rails/lib/version.rb
1009
1043
  - pg_rails/scss/bootstrap_overrides.scss
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PgEngine
4
- module RequireTenantSet
5
- def self.included(klass)
6
- klass.before_action :require_tenant_set
7
- end
8
-
9
- def require_tenant_set
10
- return if ActsAsTenant.current_tenant.present?
11
-
12
- raise ActsAsTenant::Errors::NoTenantSet
13
- end
14
- end
15
- end
@@ -1,30 +0,0 @@
1
- module Users
2
- class AccountSwitcherController < PgEngine.config.users_controller
3
- rescue_from ActsAsTenant::Errors::NoTenantSet, with: :internal_error
4
- skip_before_action :require_tenant_set
5
-
6
- before_action do
7
- @no_main_frame = true
8
- end
9
-
10
- layout 'pg_layout/centered'
11
-
12
- around_action :set_without_tenant
13
-
14
- def set_without_tenant(&)
15
- ActsAsTenant.without_tenant(&)
16
- end
17
-
18
- def list
19
- @user_accounts = Current.user.user_accounts.kept
20
- end
21
-
22
- def switch
23
- # FIXME: handle not found
24
- scope = Current.user.user_accounts.kept
25
- user_account = scope.find(UserAccount.decode_id(params[:user_account_id]))
26
- session['current_user_account'] = user_account.id
27
- redirect_to root_path
28
- end
29
- end
30
- end
@@ -1,21 +0,0 @@
1
- module Users
2
- class InlineEditController < PgEngine.config.users_controller
3
- before_action do
4
- if current_turbo_frame.blank?
5
- render_my_component(BadRequestComponent.new, :bad_request)
6
- end
7
- end
8
-
9
- def edit
10
- model = GlobalID::Locator.locate params[:model]
11
- attribute = params[:attribute]
12
- render InlineEditComponent.new(model, attribute), layout: false
13
- end
14
-
15
- def show
16
- model = GlobalID::Locator.locate params[:model]
17
- attribute = params[:attribute]
18
- render InlineShowComponent.new(model, attribute), layout: false
19
- end
20
- end
21
- end
@@ -1,24 +0,0 @@
1
- h1 ¿Qué cuenta te gustaría utilizar?
2
-
3
- / FIXME!: user_accounts add active column
4
- - if @user_accounts.empty?
5
- p No tenés ninguna cuenta disponible
6
- - else
7
- - if @current_tenant_set_by_domain_or_subdomain
8
- p Estás en el dominio de #{ActsAsTenant.current_tenant} (#{request.host})
9
- p
10
- | Para cambiar de cuenta vas a tener que iniciar sesión en el dominio
11
- |< de Bien o de la cuenta específica a la que quieras cambiar
12
-
13
- ul.m-auto.list-group style="max-width: 20em"
14
- - @user_accounts.each do |user_account|
15
- li.list-group-item
16
- - if @current_tenant_set_by_domain_or_subdomain
17
- = user_account.account
18
- - elsif user_account.account == ActsAsTenant.current_tenant
19
- b
20
- = user_account.account
21
- | (Actual)
22
- - else
23
- = link_to user_account.account, users_account_switch_path(user_account),
24
- 'data-turbo-method': :post
@@ -1 +0,0 @@
1
- h1 Dashboard
@@ -1,84 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe 'redirection' do
4
- let(:logged_user) { create :user }
5
-
6
- before do
7
- sign_in logged_user
8
- end
9
-
10
- context 'when switcher controller raises no tenant set' do
11
- # This is to prevent a redirect loop
12
- before do
13
- allow_any_instance_of(User).to receive(:user_accounts).and_raise(ActsAsTenant::Errors::NoTenantSet)
14
- end
15
-
16
- it 'shows the error' do
17
- get '/u/switcher'
18
-
19
- expect(response).to have_http_status(:internal_server_error)
20
- end
21
- end
22
-
23
- it do
24
- get '/u/cosas'
25
-
26
- expect(response).to have_http_status(:ok)
27
- end
28
-
29
- context 'when account is discarded' do
30
- it do
31
- get '/u/cosas'
32
- expect(response.body).to include 'No hay ningún coso que mostrar'
33
- logged_user.user_accounts.first.account.discard!
34
- get '/u/cosas'
35
- expect(response).to redirect_to users_account_switcher_path
36
- end
37
- end
38
-
39
- context 'when has been removed from account' do
40
- let!(:other_account) { create :account }
41
- let!(:other_user_account) do
42
- ActsAsTenant.with_tenant(other_account) do
43
- logged_user.user_accounts.create!
44
- end
45
- end
46
-
47
- before do
48
- third_account = create :account
49
- ActsAsTenant.with_tenant(third_account) do
50
- logged_user.user_accounts.create!
51
- end
52
- end
53
-
54
- it 'redirects to switcher' do
55
- get '/u/cosas'
56
- expect(response).to redirect_to users_account_switcher_path
57
- follow_redirect!
58
- expect(response.body).to include '¿Qué cuenta te gustaría utilizar?'
59
- post "/u/switcher/#{other_user_account.to_param}"
60
- expect(response).to redirect_to(root_path)
61
- follow_redirect!
62
- get '/u/cosas'
63
- expect(response).to have_http_status(:ok)
64
- expect(response.body).to include other_account.to_s
65
- expect(response.body).to include 'No hay ningún coso que mostrar'
66
- other_user_account.destroy!
67
- get '/u/cosas'
68
- expect(response).to redirect_to users_account_switcher_path
69
- end
70
- end
71
-
72
- context 'when belongs to other account' do
73
- before do
74
- create :account, subdomain: 'other'
75
- host! 'other.example.com'
76
- end
77
-
78
- it do
79
- get '/u/cosas'
80
-
81
- expect(response).to redirect_to new_user_session_path
82
- end
83
- end
84
- end