pg_rails 7.4.2 → 7.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/pg_associable/spec/system/associable_spec.rb +5 -4
- data/pg_engine/app/controllers/admin/accounts_controller.rb +4 -6
- data/pg_engine/app/controllers/admin/email_logs_controller.rb +0 -2
- data/pg_engine/app/controllers/admin/emails_controller.rb +0 -2
- data/pg_engine/app/controllers/admin/user_accounts_controller.rb +0 -2
- data/pg_engine/app/controllers/admin/users_controller.rb +2 -3
- data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +3 -0
- data/pg_engine/app/controllers/pg_engine/base_controller.rb +50 -7
- data/pg_engine/app/controllers/pg_engine/require_sign_in.rb +1 -1
- data/pg_engine/app/controllers/users/account_switcher_controller.rb +19 -0
- data/pg_engine/app/helpers/pg_engine/form_helper.rb +0 -1
- data/pg_engine/app/helpers/pg_engine/route_helper.rb +11 -5
- data/pg_engine/app/lib/pg_engine/filtros_builder.rb +2 -1
- data/pg_engine/app/models/account.rb +4 -0
- data/pg_engine/app/models/current.rb +5 -5
- data/pg_engine/app/models/user.rb +36 -5
- data/pg_engine/app/models/user_account.rb +1 -0
- data/pg_engine/app/policies/user_account_policy.rb +1 -0
- data/pg_engine/app/policies/user_policy.rb +6 -13
- data/pg_engine/app/views/admin/accounts/_form.html.slim +2 -0
- data/pg_engine/app/views/pg_engine/base/index.html.slim +1 -1
- data/pg_engine/app/views/users/account_switcher/list.html.slim +6 -0
- data/pg_engine/config/initializers/acts_as_tenant.rb +38 -0
- data/pg_engine/config/routes.rb +4 -0
- data/pg_engine/db/migrate/20240905154330_account_tenant_columns.rb +10 -0
- data/pg_engine/db/seeds.rb +13 -4
- data/pg_engine/lib/pg_engine/configuracion.rb +3 -17
- data/pg_engine/lib/pg_engine/engine.rb +0 -1
- data/pg_engine/lib/pg_engine/utils/pg_logger.rb +2 -1
- data/pg_engine/lib/pg_engine.rb +5 -0
- data/pg_engine/spec/components/previews/alert_component_preview/tables.html.slim +18 -12
- data/pg_engine/spec/controllers/admin/accounts_controller_spec.rb +2 -2
- data/pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb +4 -3
- data/pg_engine/spec/controllers/admin/users_controller_spec.rb +9 -3
- data/pg_engine/spec/models/user_spec.rb +11 -4
- data/pg_engine/spec/requests/base_controller_requests_spec.rb +1 -1
- data/pg_engine/spec/requests/users/base_controller_spec.rb +15 -0
- data/pg_engine/spec/requests/users/switcher_spec.rb +60 -0
- data/pg_engine/spec/system/breadcrumbs_spec.rb +6 -6
- data/pg_engine/spec/system/date_selector_spec.rb +1 -1
- data/pg_engine/spec/system/destroy_spec.rb +3 -3
- data/pg_engine/spec/system/modal_windows_spec.rb +5 -5
- data/pg_engine/spec/system/page_sizes_spec.rb +2 -2
- data/pg_engine/spec/system/signup_spec.rb +4 -4
- data/pg_engine/spec/system/tenants_spec.rb +55 -0
- data/pg_engine/spec/system/tooltips_spec.rb +0 -1
- data/pg_layout/app/views/devise/sessions/new.html.erb +4 -0
- data/pg_layout/app/views/pg_layout/_sidebar.html.erb +8 -0
- data/pg_rails/lib/version.rb +1 -1
- data/pg_rails/scss/pg_rails.scss +1 -0
- data/pg_scaffold/lib/generators/pg_pundit/templates/policy.rb +1 -1
- data/pg_scaffold/lib/generators/pg_rails/system_spec/templates/system_spec.rb +1 -1
- data/pg_scaffold/lib/generators/pg_rspec/scaffold/templates/controller_spec.rb +0 -2
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9044a5f343884a27bcfdb2be81907fcaaa743b4c1419c4dd1646214a50c5f7e
|
4
|
+
data.tar.gz: 2542d054eb7ec2ae29e95fdff5a7a0d8cccdef4d57e5a7073b4c0fe945f91fff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19ebd2bc479aab28961ba3280a2c0bf276e202501eecfc0474863a00e89882c79bef6c369e9d1ae7a533ad9118716389af0964ae66395a34ff0572011fb5e4ac
|
7
|
+
data.tar.gz: 5a37d34ab77355940e8c8988af1a9c4d839069b9b37bf645088ea5325c18f8e4829c99ae31877c53195d08caf22bae6ba01efa0d55cf8d95872056a481d51473
|
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|
3
3
|
describe 'Associable' do
|
4
4
|
let(:user) { create :user, :developer }
|
5
5
|
|
6
|
-
let(:path) { '/
|
6
|
+
let(:path) { '/a/cosas/new' }
|
7
7
|
|
8
8
|
before do
|
9
9
|
login_as user
|
@@ -16,16 +16,17 @@ describe 'Associable' do
|
|
16
16
|
find('.cosa_categoria_de_cosa input[type=text]').click
|
17
17
|
expect(page).to have_text :all, 'Nuevo'
|
18
18
|
find('.cosa_categoria_de_cosa .list-group-item').click
|
19
|
+
select Account.first.to_s
|
19
20
|
fill_in 'categoria_de_cosa_nombre', with: 'la categoría'
|
20
21
|
select 'Completar', from: 'categoria_de_cosa_tipo'
|
21
22
|
click_on 'Agregar Categoría de cosa'
|
22
23
|
click_on 'Cargar Coso'
|
23
|
-
expect(page).to have_text '
|
24
|
+
expect(page).to have_text 'La cosa'
|
24
25
|
end
|
25
26
|
|
26
27
|
context 'cuando crea desde el nested' do
|
27
28
|
let!(:categ) { create :categoria_de_cosa }
|
28
|
-
let(:path) { "/
|
29
|
+
let(:path) { "/a/categoria_de_cosas/#{categ.hashid}/cosas/new" }
|
29
30
|
|
30
31
|
it do
|
31
32
|
input = find_by_id('cosa_categoria_de_cosa')
|
@@ -36,7 +37,7 @@ describe 'Associable' do
|
|
36
37
|
context 'cuando edita desde el nested' do
|
37
38
|
let!(:categ) { create :categoria_de_cosa }
|
38
39
|
let!(:cosa) { create :cosa, categoria_de_cosa: categ }
|
39
|
-
let(:path) { "/
|
40
|
+
let(:path) { "/a/categoria_de_cosas/#{categ.hashid}/cosas/#{cosa.id}/edit" }
|
40
41
|
|
41
42
|
it do
|
42
43
|
ele = find_by_id('cosa_categoria_de_cosa_id', visible: :all)
|
@@ -12,24 +12,22 @@ module Admin
|
|
12
12
|
|
13
13
|
before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
|
14
14
|
|
15
|
-
add_breadcrumb Account.nombre_plural, :admin_accounts_path
|
16
|
-
|
17
15
|
private
|
18
16
|
|
19
17
|
def atributos_permitidos
|
20
|
-
%i[plan nombre]
|
18
|
+
%i[plan nombre domain subdomain]
|
21
19
|
end
|
22
20
|
|
23
21
|
def atributos_para_buscar
|
24
|
-
|
22
|
+
atributos_permitidos
|
25
23
|
end
|
26
24
|
|
27
25
|
def atributos_para_listar
|
28
|
-
|
26
|
+
atributos_permitidos
|
29
27
|
end
|
30
28
|
|
31
29
|
def atributos_para_mostrar
|
32
|
-
|
30
|
+
atributos_permitidos
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
@@ -12,8 +12,6 @@ module Admin
|
|
12
12
|
|
13
13
|
before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
|
14
14
|
|
15
|
-
add_breadcrumb EmailLog.nombre_plural, :admin_email_logs_path
|
16
|
-
|
17
15
|
before_action do
|
18
16
|
@actions = [
|
19
17
|
["Mailgun sync: #{ENV.fetch('MAILGUN_DOMAIN', nil)}", mailgun_sync_admin_email_logs_path, {
|
@@ -12,8 +12,6 @@ module Admin
|
|
12
12
|
|
13
13
|
before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
|
14
14
|
|
15
|
-
add_breadcrumb Email.nombre_plural, :admin_emails_path
|
16
|
-
|
17
15
|
after_action only: :create do
|
18
16
|
if @saved
|
19
17
|
PgEngine::AdminMailer.with(email_object: @email).admin_mail.deliver_later
|
@@ -16,11 +16,10 @@ module Admin
|
|
16
16
|
|
17
17
|
before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
|
18
18
|
|
19
|
-
add_breadcrumb User.nombre_plural, :admin_users_path
|
20
|
-
|
21
19
|
def create
|
22
20
|
@user.skip_confirmation!
|
23
|
-
@user.
|
21
|
+
@user.orphan = true
|
22
|
+
|
24
23
|
pg_respond_create
|
25
24
|
end
|
26
25
|
|
@@ -2,12 +2,51 @@
|
|
2
2
|
|
3
3
|
module PgEngine
|
4
4
|
# rubocop:disable Rails/ApplicationController
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
5
6
|
class BaseController < ActionController::Base
|
7
|
+
# Importante que esta línea esté al principio
|
8
|
+
protect_from_forgery with: :exception
|
9
|
+
|
10
|
+
set_current_tenant_by_subdomain_or_domain(:account, :subdomain, :domain)
|
11
|
+
set_current_tenant_through_filter
|
12
|
+
|
6
13
|
before_action do
|
14
|
+
Current.user = current_user
|
7
15
|
Current.controller = self
|
8
|
-
end
|
9
16
|
|
17
|
+
# if ActsAsTenant.current_tenant.blank? && !global_domain?
|
18
|
+
# raise ActsAsTenant::Errors::NoTenantSet
|
19
|
+
# end
|
20
|
+
|
21
|
+
if Current.user.present?
|
22
|
+
if ActsAsTenant.current_tenant.present?
|
23
|
+
unless Current.user.user_accounts.exists?(account: ActsAsTenant.current_tenant)
|
24
|
+
sign_out(Current.user)
|
25
|
+
throw :warden, scope: :user, message: :invalid
|
26
|
+
end
|
27
|
+
|
28
|
+
else
|
29
|
+
account = if session['current_user_account'].present?
|
30
|
+
UserAccount.where(id: session['current_user_account']).first&.account
|
31
|
+
elsif Current.user.user_accounts.count == 1
|
32
|
+
Current.user.user_accounts.first
|
33
|
+
end
|
34
|
+
set_current_tenant(account)
|
35
|
+
# FIXME: un concern que redirija al switcher si no hay current tenant
|
36
|
+
end
|
37
|
+
Current.account = ActsAsTenant.current_tenant
|
38
|
+
end
|
39
|
+
end
|
10
40
|
# rubocop:enable Rails/ApplicationController
|
41
|
+
|
42
|
+
# :nocov:
|
43
|
+
def global_domain?
|
44
|
+
return true if Rails.env.test?
|
45
|
+
|
46
|
+
request.host.in? PgEngine.config.global_domains
|
47
|
+
end
|
48
|
+
# :nocov:
|
49
|
+
|
11
50
|
include Pundit::Authorization
|
12
51
|
include PrintHelper
|
13
52
|
include PostgresHelper
|
@@ -25,10 +64,11 @@ module PgEngine
|
|
25
64
|
end
|
26
65
|
end
|
27
66
|
|
28
|
-
protect_from_forgery with: :exception
|
29
|
-
|
30
67
|
rescue_from StandardError, with: :internal_error
|
68
|
+
rescue_from ActsAsTenant::Errors::NoTenantSet, with: :no_tenant_set
|
69
|
+
|
31
70
|
rescue_from PgEngine::BadUserInput, with: :bad_user_input
|
71
|
+
|
32
72
|
rescue_from ActionController::InvalidAuthenticityToken,
|
33
73
|
with: :invalid_authenticity_token
|
34
74
|
|
@@ -38,6 +78,12 @@ module PgEngine
|
|
38
78
|
redirect_to e.url
|
39
79
|
end
|
40
80
|
|
81
|
+
def no_tenant_set(error)
|
82
|
+
return internal_error(error) if Current.user.blank?
|
83
|
+
|
84
|
+
redirect_to users_account_switcher_path
|
85
|
+
end
|
86
|
+
|
41
87
|
def bad_user_input(error)
|
42
88
|
render_my_component(BadUserInputComponent.new(error_msg: error.message), :bad_request)
|
43
89
|
end
|
@@ -63,10 +109,6 @@ module PgEngine
|
|
63
109
|
render_my_component(InternalErrorComponent.new, :ok)
|
64
110
|
end
|
65
111
|
|
66
|
-
before_action do
|
67
|
-
Current.user = current_user
|
68
|
-
end
|
69
|
-
|
70
112
|
helper_method :dev_user_or_env?
|
71
113
|
def dev_user_or_env?
|
72
114
|
Rails.env.development? || dev_user?
|
@@ -181,4 +223,5 @@ module PgEngine
|
|
181
223
|
redirect_back fallback_location: root_path
|
182
224
|
end
|
183
225
|
end
|
226
|
+
# rubocop:enable Metrics/ClassLength
|
184
227
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Users
|
2
|
+
class AccountSwitcherController < PgEngine.config.users_controller
|
3
|
+
rescue_from ActsAsTenant::Errors::NoTenantSet, with: :internal_error
|
4
|
+
|
5
|
+
before_action do
|
6
|
+
@no_main_frame = true
|
7
|
+
end
|
8
|
+
|
9
|
+
def list
|
10
|
+
@user_accounts = Current.user.user_accounts
|
11
|
+
end
|
12
|
+
|
13
|
+
def switch
|
14
|
+
user_account = UserAccount.find(params[:user_account_id])
|
15
|
+
session['current_user_account'] = user_account.id
|
16
|
+
redirect_to root_path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,21 +3,25 @@
|
|
3
3
|
module PgEngine
|
4
4
|
module RouteHelper
|
5
5
|
class NamespaceDeductor
|
6
|
-
def self.
|
6
|
+
def self.controller(context)
|
7
7
|
if context.respond_to?(:request) && context.request
|
8
8
|
# Controllers
|
9
|
-
context
|
9
|
+
context
|
10
10
|
elsif context.respond_to?(:helpers) && context.helpers
|
11
11
|
# Decorators
|
12
|
-
context.helpers.
|
12
|
+
context.helpers.controller
|
13
13
|
elsif context.respond_to?(:template) && context.template
|
14
14
|
# FormBuilders
|
15
|
-
context.template.
|
15
|
+
context.template.controller
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.current_route(context)
|
20
|
-
|
20
|
+
controller = controller(context)
|
21
|
+
# Sólo si hay un controller de verdá
|
22
|
+
return if controller.instance_of? ApplicationController
|
23
|
+
|
24
|
+
req = controller.request
|
21
25
|
Rails.application.routes.recognize_path(req.path, method: req.env['REQUEST_METHOD'])
|
22
26
|
end
|
23
27
|
|
@@ -25,6 +29,8 @@ module PgEngine
|
|
25
29
|
return Current.namespace if Current.namespace.present?
|
26
30
|
|
27
31
|
route = current_route(context)
|
32
|
+
return if route.blank?
|
33
|
+
|
28
34
|
parts = route[:controller].split('/')
|
29
35
|
return unless parts.length > 1
|
30
36
|
|
@@ -4,9 +4,9 @@ class Current < ActiveSupport::CurrentAttributes
|
|
4
4
|
|
5
5
|
# resets { Time.zone = nil }
|
6
6
|
|
7
|
-
def user=(user)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
# def user=(user)
|
8
|
+
# super
|
9
|
+
#
|
10
|
+
# Time.zone = user.time_zone
|
11
|
+
# end
|
12
12
|
end
|
@@ -37,7 +37,22 @@ class User < ApplicationRecord
|
|
37
37
|
include Discard::Model
|
38
38
|
|
39
39
|
has_many :user_accounts
|
40
|
+
|
41
|
+
# Hace falta?
|
40
42
|
has_many :accounts, through: :user_accounts
|
43
|
+
|
44
|
+
# default_scope lambda {
|
45
|
+
# if ActsAsTenant.current_tenant.present?
|
46
|
+
# joins(:user_accounts).where('user_accounts.account_id': ActsAsTenant.current_tenant.id)
|
47
|
+
# else
|
48
|
+
# raise ActsAsTenant::Errors::NoTenantSet unless Current.user.blank? || ActsAsTenant.unscoped?
|
49
|
+
|
50
|
+
# # Aún no autenticó devise o es el admin
|
51
|
+
# all
|
52
|
+
|
53
|
+
# end
|
54
|
+
# }
|
55
|
+
|
41
56
|
has_many :notifications, as: :recipient, class_name: 'Noticed::Notification'
|
42
57
|
|
43
58
|
validates :nombre, :apellido, presence: true
|
@@ -57,14 +72,23 @@ class User < ApplicationRecord
|
|
57
72
|
attr_accessor :orphan
|
58
73
|
|
59
74
|
after_create do
|
60
|
-
# TODO: si fue invitado, sumar a la account del invitador
|
61
75
|
create_account unless orphan
|
62
76
|
end
|
63
77
|
|
64
78
|
def create_account
|
65
|
-
|
79
|
+
# rubocop:disable Rails/Presence
|
80
|
+
account =
|
81
|
+
if ActsAsTenant.current_tenant.present?
|
82
|
+
# FIXME!: raise PgEngine::Error unless invited
|
83
|
+
ActsAsTenant.current_tenant
|
84
|
+
else
|
85
|
+
Account.create(nombre: email, plan: 0)
|
86
|
+
end
|
87
|
+
# rubocop:enable Rails/Presence
|
88
|
+
|
66
89
|
ua = user_accounts.create(account:)
|
67
|
-
|
90
|
+
|
91
|
+
raise(Error, 'no se pudo crear la cuenta') unless ua.persisted?
|
68
92
|
end
|
69
93
|
|
70
94
|
def password_required?
|
@@ -87,9 +111,16 @@ class User < ApplicationRecord
|
|
87
111
|
|
88
112
|
class Error < PgEngine::Error; end
|
89
113
|
|
90
|
-
def
|
114
|
+
def default_account
|
91
115
|
raise Error, 'El usuario debe tener cuenta' if accounts.empty?
|
92
116
|
|
93
|
-
|
117
|
+
user_accounts.first.account
|
118
|
+
# throw :warden, scope: :user, message: :user_not_belongs_to_account
|
119
|
+
end
|
120
|
+
|
121
|
+
deprecate :current_account, deprecator: PgEngine.deprecator
|
122
|
+
|
123
|
+
def current_account
|
124
|
+
ActsAsTenant.current_tenant
|
94
125
|
end
|
95
126
|
end
|
@@ -4,17 +4,6 @@
|
|
4
4
|
|
5
5
|
class UserPolicy < ApplicationPolicy
|
6
6
|
class Scope < ApplicationPolicy::Scope
|
7
|
-
def resolve
|
8
|
-
if policy.acceso_total?
|
9
|
-
if Current.account.present?
|
10
|
-
scope.joins(:user_accounts).where('user_accounts.account_id': Current.account.id)
|
11
|
-
else
|
12
|
-
scope.none
|
13
|
-
end
|
14
|
-
else
|
15
|
-
scope.none
|
16
|
-
end
|
17
|
-
end
|
18
7
|
end
|
19
8
|
|
20
9
|
# def puede_editar?
|
@@ -29,7 +18,11 @@ class UserPolicy < ApplicationPolicy
|
|
29
18
|
# acceso_total? && !record.readonly?
|
30
19
|
# end
|
31
20
|
|
32
|
-
def
|
33
|
-
user.
|
21
|
+
def base_access_to_record?
|
22
|
+
user.developer? || user == record
|
34
23
|
end
|
24
|
+
|
25
|
+
# def base_access_to_collection?
|
26
|
+
# user&.present?
|
27
|
+
# end
|
35
28
|
end
|
@@ -22,7 +22,7 @@ div
|
|
22
22
|
thead.table-light
|
23
23
|
tr
|
24
24
|
- atributos_para_listar.each do |att|
|
25
|
-
th = encabezado att, ordenable: true
|
25
|
+
th.text-nowrap style="font-size: 0.8em" = encabezado att, ordenable: true
|
26
26
|
th.text-end
|
27
27
|
- unless @export_link == false
|
28
28
|
= @clase_modelo.new.decorate.export_link(request.url)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
ActsAsTenant.configure do |config|
|
2
|
+
config.require_tenant = true
|
3
|
+
# config.require_tenant = lambda do |options|
|
4
|
+
# # if options[:scope] == User && true # global_domain?
|
5
|
+
# # # tal vez en algunos casos de devise sí requeriría el tenant?
|
6
|
+
# # # creería que no, el único lugar en donde se debería queriar
|
7
|
+
# # # User es en devise y es para obtener el current_user
|
8
|
+
# # # hay que ver luego qué pasa con invitable
|
9
|
+
# # false
|
10
|
+
# # else
|
11
|
+
# # true
|
12
|
+
# # end
|
13
|
+
# end
|
14
|
+
|
15
|
+
# Customize the query for loading the tenant in background jobs
|
16
|
+
# config.job_scope = ->{ all }
|
17
|
+
end
|
18
|
+
|
19
|
+
SET_TENANT_PROC = lambda do
|
20
|
+
if defined?(Rails::Console)
|
21
|
+
puts "> ActsAsTenant.current_tenant = Account.first"
|
22
|
+
ActsAsTenant.current_tenant = Account.first
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Rails.application.configure do
|
27
|
+
if Rails.env.development?
|
28
|
+
# Set the tenant to the first account in development on load
|
29
|
+
config.after_initialize do
|
30
|
+
SET_TENANT_PROC.call
|
31
|
+
end
|
32
|
+
|
33
|
+
# Reset the tenant after calling 'reload!' in the console
|
34
|
+
ActiveSupport::Reloader.to_complete do
|
35
|
+
SET_TENANT_PROC.call
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/pg_engine/config/routes.rb
CHANGED
@@ -21,6 +21,10 @@ Rails.application.routes.draw do
|
|
21
21
|
post 'notifications/mark_as_seen', to: 'notifications#mark_as_seen'
|
22
22
|
post 'notifications/mark_as_unseen', to: 'notifications#mark_as_unseen'
|
23
23
|
get 'date_jumper/jump'
|
24
|
+
scope controller: 'account_switcher', path: 'switcher' do
|
25
|
+
get '', action: 'list', as: 'account_switcher'
|
26
|
+
post ':user_account_id', action: 'switch', as: 'account_switch'
|
27
|
+
end
|
24
28
|
end
|
25
29
|
namespace :admin, path: 'a' do
|
26
30
|
pg_resource(:emails)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class AccountTenantColumns < ActiveRecord::Migration[7.2]
|
2
|
+
def change
|
3
|
+
add_column :accounts, :domain, :string
|
4
|
+
add_column :accounts, :subdomain, :string
|
5
|
+
|
6
|
+
add_reference :audits, :account, index: true, foreign_key: true
|
7
|
+
add_reference :emails, :account, index: true, foreign_key: true
|
8
|
+
add_reference :email_logs, :account, index: true, foreign_key: true
|
9
|
+
end
|
10
|
+
end
|
data/pg_engine/db/seeds.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
-
|
1
|
+
ActsAsTenant.without_tenant do
|
2
|
+
DatabaseCleaner.clean_with(:truncation, except: %w(ar_internal_metadata))
|
2
3
|
|
3
|
-
FactoryBot.create :user, email: 'mrosso10@gmail.com', nombre: 'Martín', apellido: 'Rosso', password: 'admin123',
|
4
|
-
confirmed_at: Time.now, developer: true
|
5
4
|
|
6
|
-
|
5
|
+
bien = FactoryBot.create :account, nombre: 'Bien', subdomain: 'bien'
|
6
|
+
uno = FactoryBot.create :user, email: 'mrosso10@gmail.com', nombre: 'Martín', apellido: 'Rosso', password: 'admin123',
|
7
|
+
confirmed_at: Time.now, developer: true, orphan: true
|
8
|
+
bien.users << uno
|
9
|
+
|
10
|
+
mal = FactoryBot.create :account, nombre: 'Mal', subdomain: 'mal'
|
11
|
+
otro = FactoryBot.create :user, email: 'mal@gmail.com', nombre: 'Mal', apellido: 'Mal', password: 'admin123',
|
12
|
+
confirmed_at: Time.now, developer: true, orphan: true
|
13
|
+
|
14
|
+
mal.users << otro
|
15
|
+
end
|
@@ -4,30 +4,16 @@
|
|
4
4
|
|
5
5
|
module PgEngine
|
6
6
|
class Configuracion
|
7
|
-
attr_accessor :
|
8
|
-
:boton_destroy, :boton_edit, :boton_show,
|
9
|
-
:boton_light, :icono_destroy, :icono_edit,
|
10
|
-
:icono_show, :boton_export, :bootstrap_version,
|
11
|
-
:users_controller
|
7
|
+
attr_accessor :users_controller, :global_domains
|
12
8
|
|
13
9
|
def initialize
|
14
|
-
@sistema_iconos = 'bi'
|
15
|
-
@clase_botones_chicos = 'btn-sm'
|
16
|
-
@boton_destroy = 'light'
|
17
|
-
@boton_export = 'warning'
|
18
|
-
@boton_edit = 'light'
|
19
|
-
@boton_show = 'light'
|
20
|
-
@boton_light = 'light'
|
21
|
-
@icono_destroy = 'trash-fill'
|
22
|
-
@icono_edit = 'pencil'
|
23
|
-
@icono_show = 'eye-fill'
|
24
|
-
@bootstrap_version = 5
|
25
|
-
|
26
10
|
if defined? UsersController
|
27
11
|
@users_controller = UsersController
|
28
12
|
elsif defined? FrontendController
|
29
13
|
@users_controller = FrontendController
|
30
14
|
end
|
15
|
+
|
16
|
+
@global_domains = ['app.localhost.com', 'test.host', 'localhost']
|
31
17
|
end
|
32
18
|
end
|
33
19
|
end
|
@@ -3,9 +3,10 @@
|
|
3
3
|
require 'rainbow'
|
4
4
|
|
5
5
|
# TODO: poder pasar blocks
|
6
|
+
# TODO: loguear paralelamente a otro file
|
6
7
|
|
7
8
|
def pg_err(*args)
|
8
|
-
if ENV.fetch('RAISE_ERRORS', false)
|
9
|
+
if ENV.fetch('RAISE_ERRORS', false) == '1'
|
9
10
|
# :nocov:
|
10
11
|
raise args.first if args.first.is_a?(Exception)
|
11
12
|
|
data/pg_engine/lib/pg_engine.rb
CHANGED
@@ -16,6 +16,7 @@ require 'rails'
|
|
16
16
|
require 'anycable'
|
17
17
|
require 'anycable-rails'
|
18
18
|
require 'anycable-rails-jwt'
|
19
|
+
require 'acts_as_tenant'
|
19
20
|
require 'cable_ready'
|
20
21
|
require 'caxlsx_rails'
|
21
22
|
require 'draper'
|
@@ -105,4 +106,8 @@ module PgEngine
|
|
105
106
|
https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;\
|
106
107
|
0,500;0,700;1,300;1,400;1,500;1,700&display=swap
|
107
108
|
URL
|
109
|
+
|
110
|
+
def self.deprecator
|
111
|
+
@deprecator ||= ActiveSupport::Deprecation.new('7.5', 'PgEngine')
|
112
|
+
end
|
108
113
|
end
|