pg_rails 7.6.16 → 7.6.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/pg_engine/app/controllers/admin/simple_user_notifiers_controller.rb +8 -7
- data/pg_engine/app/models/concerns/pg_engine/naming.rb +50 -0
- data/pg_engine/app/models/pg_engine/base_record.rb +1 -42
- data/pg_engine/app/notifiers/simple_user_notifier.rb +4 -0
- data/pg_engine/app/views/admin/simple_user_notifiers/_form.html.slim +1 -1
- data/pg_engine/lib/pg_engine/engine.rb +4 -0
- data/pg_engine/spec/models/pg_engine/base_record_spec.rb +12 -0
- data/pg_engine/spec/requests/admin/eventos_spec.rb +9 -15
- data/pg_rails/lib/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a05ebc7aa2578ab2c32a72e68dc56b958aa0787216c6703764af4d906eba4aff
|
4
|
+
data.tar.gz: 43e3d8a43d5d4b6b490de9aec4f1b122051905c81c40f699868e2015b2db314f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c9d7e326b078d50d6b5e7b8ac04f8aecfbe6217d6eb5d6984139cf1a9a9ab4f8f06e423e2b2babbfbd51266100bdd6191960a79d4b7a9a2c351f8647d3493a4
|
7
|
+
data.tar.gz: dea6b0686fe63c661a129b17a880d4158fec6fcc0430e96aaaace4444fddffd84818dabd164dee2523906824babded554cb0a10c49ed419da73b8d2c4a44baff
|
@@ -17,25 +17,25 @@ module Admin
|
|
17
17
|
|
18
18
|
# rubocop:disable Metrics/MethodLength
|
19
19
|
def create
|
20
|
-
@
|
21
|
-
# @
|
22
|
-
unless @
|
20
|
+
@simple_user_notifier = SimpleUserNotifier.new(modelo_params)
|
21
|
+
# @simple_user_notifier.message.save!
|
22
|
+
unless @simple_user_notifier.valid?
|
23
23
|
render :new, status: :unprocessable_entity
|
24
24
|
return
|
25
25
|
end
|
26
26
|
json_params_for_event = {
|
27
|
-
message: @
|
28
|
-
tooltip: @
|
27
|
+
message: @simple_user_notifier.message,
|
28
|
+
tooltip: @simple_user_notifier.tooltip
|
29
29
|
}
|
30
30
|
notifier = SimpleUserNotifier.with(json_params_for_event)
|
31
31
|
|
32
|
-
case @
|
32
|
+
case @simple_user_notifier.target
|
33
33
|
when 'todos'
|
34
34
|
notifier.deliver(User.all)
|
35
35
|
when 'devs'
|
36
36
|
notifier.deliver(User.where(developer: true))
|
37
37
|
when 'user_ids'
|
38
|
-
notifier.deliver(User.where(email: @
|
38
|
+
notifier.deliver(User.where(email: @simple_user_notifier.user_ids.split(',')))
|
39
39
|
else
|
40
40
|
# :nocov:
|
41
41
|
'shouldnt happen'
|
@@ -46,6 +46,7 @@ module Admin
|
|
46
46
|
rescue StandardError => e
|
47
47
|
# :nocov:
|
48
48
|
flash.now[:alert] = e.to_s
|
49
|
+
# @simple_user_notifier = @simple_user_notifier.decorate
|
49
50
|
render :new, status: :unprocessable_entity
|
50
51
|
# :nocov:
|
51
52
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module PgEngine
|
2
|
+
module Naming
|
3
|
+
def gender
|
4
|
+
self.class.model_name.human.downcase.ends_with?('a') ? 'f' : 'm'
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
# This is a per class variable, all subclasses of BaseRecord inherit it
|
13
|
+
# BUT **the values are independent between all of them**
|
14
|
+
attr_accessor :default_modal, :inline_editable_fields
|
15
|
+
|
16
|
+
def inline_editable?(attribute)
|
17
|
+
inline_editable_fields.present? && inline_editable_fields.include?(attribute.to_sym)
|
18
|
+
end
|
19
|
+
|
20
|
+
def ransackable_associations(_auth_object = nil)
|
21
|
+
authorizable_ransackable_associations
|
22
|
+
end
|
23
|
+
|
24
|
+
def ransackable_attributes(_auth_object = nil)
|
25
|
+
authorizable_ransackable_attributes
|
26
|
+
end
|
27
|
+
|
28
|
+
def nombre_plural
|
29
|
+
model_name.human(count: 2)
|
30
|
+
end
|
31
|
+
|
32
|
+
def nombre_singular
|
33
|
+
model_name.human(count: 1)
|
34
|
+
end
|
35
|
+
|
36
|
+
def human_attribute_name(attribute, options = {})
|
37
|
+
# Remove suffixes
|
38
|
+
if attribute.to_s.ends_with?('_text')
|
39
|
+
# Si es un enumerized
|
40
|
+
super(attribute[0..-6], options)
|
41
|
+
elsif attribute.to_s.ends_with?('_f')
|
42
|
+
# Si es un decorated method
|
43
|
+
super(attribute[0..-3], options)
|
44
|
+
else
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -7,58 +7,17 @@ module PgEngine
|
|
7
7
|
extend Enumerize
|
8
8
|
include PrintHelper
|
9
9
|
include PostgresHelper
|
10
|
+
include Naming
|
10
11
|
|
11
12
|
self.abstract_class = true
|
12
13
|
|
13
14
|
before_create :setear_creado_y_actualizado_por
|
14
15
|
before_update :setear_actualizado_por
|
15
16
|
|
16
|
-
class << self
|
17
|
-
# This is a per class variable, all subclasses of BaseRecord inherit it
|
18
|
-
# BUT **the values are independent between all of them**
|
19
|
-
attr_accessor :default_modal, :inline_editable_fields
|
20
|
-
|
21
|
-
def inline_editable?(attribute)
|
22
|
-
inline_editable_fields.present? && inline_editable_fields.include?(attribute.to_sym)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
17
|
# ransacker :search do |parent|
|
27
18
|
# parent.table[:nombre]
|
28
19
|
# end
|
29
20
|
|
30
|
-
def self.ransackable_associations(_auth_object = nil)
|
31
|
-
authorizable_ransackable_associations
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.ransackable_attributes(_auth_object = nil)
|
35
|
-
authorizable_ransackable_attributes
|
36
|
-
end
|
37
|
-
|
38
|
-
def gender
|
39
|
-
self.class.model_name.human.downcase.ends_with?('a') ? 'f' : 'm'
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.nombre_plural
|
43
|
-
model_name.human(count: 2)
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.nombre_singular
|
47
|
-
model_name.human(count: 1)
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.human_attribute_name(attribute, options = {})
|
51
|
-
if attribute.to_s.ends_with?('_text')
|
52
|
-
# Si es un enumerized
|
53
|
-
super(attribute[0..-6], options)
|
54
|
-
elsif attribute.to_s.ends_with?('_f')
|
55
|
-
# Si es un decorated method
|
56
|
-
super(attribute[0..-3], options)
|
57
|
-
else
|
58
|
-
super
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
21
|
def actions_component
|
63
22
|
ActionsComponent.new(self)
|
64
23
|
end
|
@@ -12,4 +12,16 @@ describe PgEngine::BaseRecord do
|
|
12
12
|
expect(obj).to eq described_class.human_attribute_name('bla')
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
describe '#default_modal' do
|
17
|
+
it 'the values are independent from each class' do
|
18
|
+
model_class = Class.new(described_class)
|
19
|
+
another_model_class = Class.new(described_class)
|
20
|
+
model_class.default_modal = true
|
21
|
+
another_model_class.default_modal = false
|
22
|
+
expect(model_class.default_modal).to be true
|
23
|
+
expect(another_model_class.default_modal).to be false
|
24
|
+
expect(described_class.default_modal).to be_nil
|
25
|
+
end
|
26
|
+
end
|
15
27
|
end
|
@@ -16,28 +16,23 @@ describe 'Eventos' do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'renders the event index' do
|
19
|
-
get '/a/
|
19
|
+
get '/a/simple_user_notifiers'
|
20
20
|
|
21
|
-
expect(response.body).to include '
|
21
|
+
expect(response.body).to include 'Crear simple user notifier'
|
22
22
|
end
|
23
23
|
|
24
24
|
describe 'posting events' do
|
25
25
|
subject do
|
26
|
-
get '/a/
|
26
|
+
get '/a/simple_user_notifiers/new'
|
27
27
|
expect(response.body).to include 'Tooltip'
|
28
|
-
post '/a/
|
29
|
-
|
30
|
-
type:,
|
28
|
+
post '/a/simple_user_notifiers', params: {
|
29
|
+
simple_user_notifier: {
|
31
30
|
message: 'hola',
|
32
|
-
message_text:,
|
33
|
-
subject: asunto,
|
34
31
|
user_ids:,
|
35
|
-
record_type: 'User',
|
36
|
-
record_id:,
|
37
32
|
target:
|
38
33
|
}
|
39
34
|
}
|
40
|
-
get "/a/eventos/new?event_id=#{Noticed::Event.last.id}"
|
35
|
+
# get "/a/eventos/new?event_id=#{Noticed::Event.last.id}"
|
41
36
|
end
|
42
37
|
|
43
38
|
let(:record_id) { nil }
|
@@ -83,10 +78,9 @@ describe 'Eventos' do
|
|
83
78
|
|
84
79
|
context 'cuando hay error' do
|
85
80
|
subject do
|
86
|
-
post '/a/
|
87
|
-
|
88
|
-
|
89
|
-
message: 'hola',
|
81
|
+
post '/a/simple_user_notifiers', params: {
|
82
|
+
simple_user_notifier: {
|
83
|
+
message: nil,
|
90
84
|
target:
|
91
85
|
}
|
92
86
|
}
|
data/pg_rails/lib/version.rb
CHANGED
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.6.
|
4
|
+
version: 7.6.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martín Rosso
|
@@ -743,6 +743,7 @@ files:
|
|
743
743
|
- pg_engine/app/mailers/pg_engine/base_mailer.rb
|
744
744
|
- pg_engine/app/mailers/pg_engine/user_mailer.rb
|
745
745
|
- pg_engine/app/models/account.rb
|
746
|
+
- pg_engine/app/models/concerns/pg_engine/naming.rb
|
746
747
|
- pg_engine/app/models/current.rb
|
747
748
|
- pg_engine/app/models/email.rb
|
748
749
|
- pg_engine/app/models/email_log.rb
|