pg_rails 7.0.8.pre.alpha.84 → 7.0.8.pre.alpha.85

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c61900d2d0b3a827718b84a3cab67f4851b2eb3087e7fbc1d313f0acf163bf3
4
- data.tar.gz: bfca92cbb58ba292877ccb61b15b08049a0d800fdc13408f82647e9ea7c66ee9
3
+ metadata.gz: a8e7f1383530ebb81fee806358820682f5296214306d3e7a31e552f977f84e08
4
+ data.tar.gz: c824d6e755c9048e05f30cb628ab21d991b9a737f754e5be17fc915c273d9446
5
5
  SHA512:
6
- metadata.gz: 2282deaa98881e20bd0b754c6496fc9da679214760ea45fd5f8c2f0b64a0903e1557cffb2f8d4c13b156d46e62b237113bf8f24bdba676436a404eb1e57e37c5
7
- data.tar.gz: d9ece2e6b39c53169548c253afdb18fb9707d76bc762b0b86b7cc2656e563a4efea6d303f51814aac22926effd37ef1ec1d6c6a6d00bded153476864586f6b14
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 instancia_modelo
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
@@ -21,6 +21,7 @@ module PgEngine
21
21
 
22
22
  rescue_from StandardError do |err|
23
23
  pg_err err
24
+ # TODO: agregar un backtrace
24
25
  @email_object.update_columns(status: :failed, status_detail: err.to_s) if @email_object.present?
25
26
  end
26
27
 
@@ -25,7 +25,7 @@ class MensajeContactoPolicy < ApplicationPolicy
25
25
  # acceso_total? && !record.readonly?
26
26
  # end
27
27
 
28
- def acceso_total?
28
+ def puede_crear?
29
29
  true
30
30
  end
31
31
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgEngine
4
- class ApplicationPolicy
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
- raise "esta policy se llama con la clase modelo y no con #{record.class}" unless record.class
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
- acceso_total?
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.acceso_total?
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
- acceso_total?
69
+ base_access_to_record?
76
70
  end
77
71
 
78
72
  def puede_crear?
79
- acceso_total?
73
+ base_access_to_collection?
80
74
  end
81
75
 
82
76
  def puede_borrar?
83
- acceso_total?
77
+ base_access_to_record?
84
78
  end
85
79
 
86
80
  def export?
87
- acceso_total?
81
+ base_access_to_collection?
82
+ end
83
+
84
+ def base_access_to_record?
85
+ user&.developer?
88
86
  end
89
87
 
90
- def acceso_total?
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?(:deleted?)
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 - ignored_classes
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' }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.84'
4
+ VERSION = '7.0.8-alpha.85'
5
5
  end
@@ -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.acceso_total?
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
- # acceso_total? && !record.readonly?
22
+ # base_access_to_record?
23
23
  # end
24
24
 
25
25
  # def puede_crear?
26
- # acceso_total? || user.asesor?
26
+ # base_access_to_collection?
27
27
  # end
28
28
 
29
29
  # def puede_borrar?
30
- # acceso_total? && !record.readonly?
30
+ # base_access_to_record?
31
31
  # end
32
32
 
33
- # def acceso_total?
34
- # user.developer?
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.84
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/application_policy.rb
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