pg_rails 7.0.8.pre.alpha.84 → 7.0.8.pre.alpha.85
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/concerns/pg_engine/resource.rb +1 -1
- data/pg_engine/app/mailers/pg_engine/base_mailer.rb +1 -0
- data/pg_engine/app/policies/mensaje_contacto_policy.rb +1 -1
- data/pg_engine/app/policies/pg_engine/{application_policy.rb → base_policy.rb} +14 -18
- data/pg_engine/lib/pg_engine/utils/check_invalid_records.rb +10 -2
- data/pg_engine/spec/controllers/public/mensaje_contactos_controller_spec.rb +0 -6
- data/pg_rails/lib/version.rb +1 -1
- data/pg_scaffold/lib/generators/pg_pundit/templates/policy.rb +10 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8e7f1383530ebb81fee806358820682f5296214306d3e7a31e552f977f84e08
|
4
|
+
data.tar.gz: c824d6e755c9048e05f30cb628ab21d991b9a737f754e5be17fc915c273d9446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e96376b503168349f4383a6f12a9b617c0da2454b3a03e490e48bebe5bb4ee7732581fd8b9757e2ade08559c5a3d9b2b189f23b2d095740a318cd5964fa3dab2
|
7
|
+
data.tar.gz: f2f9f557c97be28535b81cc28efcf6aca1e306ef3aa22e1b97941161f468bf2381038c4c952bdd9da56ea233fe04e36e1f206baf424711b6596c83457d711328
|
@@ -229,7 +229,7 @@ module PgEngine
|
|
229
229
|
instancia_modelo.assign_attributes(modelo_params) if action_name.in? %w[update]
|
230
230
|
end
|
231
231
|
|
232
|
-
authorize
|
232
|
+
Current.user&.developer? || authorize(instancia_modelo)
|
233
233
|
|
234
234
|
# TODO: problema en create y update cuando falla la validacion
|
235
235
|
# Reproducir el error antes de arreglarlo
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module PgEngine
|
4
|
-
class
|
4
|
+
class BasePolicy
|
5
5
|
attr_reader :user, :record
|
6
6
|
|
7
7
|
def initialize(user, record)
|
@@ -9,19 +9,13 @@ module PgEngine
|
|
9
9
|
@record = record
|
10
10
|
end
|
11
11
|
|
12
|
-
def editar_en_lugar?
|
13
|
-
puede_editar?
|
14
|
-
end
|
15
|
-
|
16
12
|
def index?
|
17
|
-
|
18
|
-
|
19
|
-
acceso_total? || Pundit.policy_scope!(user, record).any?
|
13
|
+
base_access_to_collection?
|
20
14
|
end
|
21
15
|
|
22
16
|
def show?
|
23
17
|
# scope.where(id: record.id).exists?
|
24
|
-
|
18
|
+
base_access_to_record?
|
25
19
|
end
|
26
20
|
|
27
21
|
def create?
|
@@ -57,7 +51,7 @@ module PgEngine
|
|
57
51
|
end
|
58
52
|
|
59
53
|
def resolve
|
60
|
-
if policy.
|
54
|
+
if policy.base_access_to_collection?
|
61
55
|
scope.all
|
62
56
|
else
|
63
57
|
scope.none
|
@@ -72,29 +66,31 @@ module PgEngine
|
|
72
66
|
end
|
73
67
|
|
74
68
|
def puede_editar?
|
75
|
-
|
69
|
+
base_access_to_record?
|
76
70
|
end
|
77
71
|
|
78
72
|
def puede_crear?
|
79
|
-
|
73
|
+
base_access_to_collection?
|
80
74
|
end
|
81
75
|
|
82
76
|
def puede_borrar?
|
83
|
-
|
77
|
+
base_access_to_record?
|
84
78
|
end
|
85
79
|
|
86
80
|
def export?
|
87
|
-
|
81
|
+
base_access_to_collection?
|
82
|
+
end
|
83
|
+
|
84
|
+
def base_access_to_record?
|
85
|
+
user&.developer?
|
88
86
|
end
|
89
87
|
|
90
|
-
def
|
88
|
+
def base_access_to_collection?
|
91
89
|
user&.developer?
|
92
90
|
end
|
93
91
|
|
94
92
|
def objeto_borrado?
|
95
|
-
if record.respond_to?(:
|
96
|
-
record.deleted?
|
97
|
-
elsif record.respond_to?(:discarded?)
|
93
|
+
if record.respond_to?(:discarded?)
|
98
94
|
record.discarded?
|
99
95
|
else
|
100
96
|
false
|
@@ -20,15 +20,23 @@ module PgEngine
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def classes
|
23
|
-
ActiveRecord::Base.descendants
|
23
|
+
all = ActiveRecord::Base.descendants.select { |m| m.table_name.present? }
|
24
|
+
all - ignored_classes
|
24
25
|
end
|
25
26
|
|
26
27
|
def ignored_classes
|
27
28
|
[
|
29
|
+
ActionText::Record,
|
30
|
+
ActionMailbox::Record,
|
31
|
+
ActiveAdmin::Comment,
|
28
32
|
ActiveStorage::Record,
|
29
33
|
PgEngine::BaseRecord,
|
30
|
-
ActiveAdmin::Comment,
|
31
34
|
Audited::Audit,
|
35
|
+
ActionText::RichText,
|
36
|
+
ActionText::EncryptedRichText,
|
37
|
+
ActionMailbox::InboundEmail,
|
38
|
+
ActiveStorage::VariantRecord,
|
39
|
+
ActiveStorage::Attachment,
|
32
40
|
ActiveStorage::Blob,
|
33
41
|
ApplicationRecord
|
34
42
|
]
|
@@ -42,12 +42,6 @@ RSpec.describe Public::MensajeContactosController do
|
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
-
let(:logged_user) { create :user, :developer }
|
46
|
-
|
47
|
-
before do
|
48
|
-
sign_in logged_user if logged_user.present?
|
49
|
-
end
|
50
|
-
|
51
45
|
describe 'routing' do
|
52
46
|
it 'routes GET index correctly' do
|
53
47
|
route = { get: '/contacto/new' }
|
data/pg_rails/lib/version.rb
CHANGED
@@ -10,7 +10,7 @@ require_dependency "<%= namespaced_path %>/application_policy"
|
|
10
10
|
class <%= class_name %>Policy < ApplicationPolicy
|
11
11
|
class Scope < ApplicationPolicy::Scope
|
12
12
|
# def resolve
|
13
|
-
# if policy.
|
13
|
+
# if policy.base_access_to_collection?
|
14
14
|
# scope.all
|
15
15
|
# else
|
16
16
|
# scope.none
|
@@ -19,19 +19,23 @@ class <%= class_name %>Policy < ApplicationPolicy
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# def puede_editar?
|
22
|
-
#
|
22
|
+
# base_access_to_record?
|
23
23
|
# end
|
24
24
|
|
25
25
|
# def puede_crear?
|
26
|
-
#
|
26
|
+
# base_access_to_collection?
|
27
27
|
# end
|
28
28
|
|
29
29
|
# def puede_borrar?
|
30
|
-
#
|
30
|
+
# base_access_to_record?
|
31
31
|
# end
|
32
32
|
|
33
|
-
# def
|
34
|
-
#
|
33
|
+
# def base_access_to_record?
|
34
|
+
# base_access_to_collection? && record.account == Current.account
|
35
|
+
# end
|
36
|
+
|
37
|
+
# def base_access_to_collection?
|
38
|
+
# user.present?
|
35
39
|
# end
|
36
40
|
end
|
37
41
|
<% end -%>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.85
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martín Rosso
|
@@ -1002,7 +1002,7 @@ files:
|
|
1002
1002
|
- pg_engine/app/policies/email_log_policy.rb
|
1003
1003
|
- pg_engine/app/policies/email_policy.rb
|
1004
1004
|
- pg_engine/app/policies/mensaje_contacto_policy.rb
|
1005
|
-
- pg_engine/app/policies/pg_engine/
|
1005
|
+
- pg_engine/app/policies/pg_engine/base_policy.rb
|
1006
1006
|
- pg_engine/app/policies/user_account_policy.rb
|
1007
1007
|
- pg_engine/app/policies/user_policy.rb
|
1008
1008
|
- pg_engine/app/policies/user_registration_policy.rb
|