pg_rails 7.6.15 → 7.6.17
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/admin/simple_user_notifiers_controller.rb +76 -0
- 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 +21 -0
- data/pg_engine/app/views/admin/simple_user_notifiers/_form.html.slim +14 -0
- data/pg_engine/app/views/admin/simple_user_notifiers/show.html.slim +29 -0
- data/pg_engine/config/routes.rb +1 -1
- data/pg_engine/lib/pg_engine/engine.rb +4 -0
- data/pg_engine/lib/pg_engine/navigator.rb +1 -1
- 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 +6 -6
- data/pg_engine/app/controllers/admin/eventos_controller.rb +0 -83
- data/pg_engine/app/models/evento.rb +0 -27
- data/pg_engine/app/views/admin/eventos/index.html.slim +0 -6
- data/pg_engine/app/views/admin/eventos/new.html.slim +0 -16
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
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Admin
|
|
2
|
+
class SimpleUserNotifiersController < AdminController
|
|
3
|
+
include PgEngine::Resource
|
|
4
|
+
|
|
5
|
+
self.clase_modelo = SimpleUserNotifier
|
|
6
|
+
|
|
7
|
+
before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
|
|
8
|
+
|
|
9
|
+
def column_options_for(object, attribute)
|
|
10
|
+
case attribute
|
|
11
|
+
when :message
|
|
12
|
+
{ class: 'column-truncate-30', title: object.send(attribute).to_s }
|
|
13
|
+
else
|
|
14
|
+
super
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# rubocop:disable Metrics/MethodLength
|
|
19
|
+
def create
|
|
20
|
+
@simple_user_notifier = SimpleUserNotifier.new(modelo_params)
|
|
21
|
+
# @simple_user_notifier.message.save!
|
|
22
|
+
unless @simple_user_notifier.valid?
|
|
23
|
+
render :new, status: :unprocessable_entity
|
|
24
|
+
return
|
|
25
|
+
end
|
|
26
|
+
json_params_for_event = {
|
|
27
|
+
message: @simple_user_notifier.message,
|
|
28
|
+
tooltip: @simple_user_notifier.tooltip
|
|
29
|
+
}
|
|
30
|
+
notifier = SimpleUserNotifier.with(json_params_for_event)
|
|
31
|
+
|
|
32
|
+
case @simple_user_notifier.target
|
|
33
|
+
when 'todos'
|
|
34
|
+
notifier.deliver(User.all)
|
|
35
|
+
when 'devs'
|
|
36
|
+
notifier.deliver(User.where(developer: true))
|
|
37
|
+
when 'user_ids'
|
|
38
|
+
notifier.deliver(User.where(email: @simple_user_notifier.user_ids.split(',')))
|
|
39
|
+
else
|
|
40
|
+
# :nocov:
|
|
41
|
+
'shouldnt happen'
|
|
42
|
+
# :nocov:
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
redirect_to admin_simple_user_notifiers_path
|
|
46
|
+
rescue StandardError => e
|
|
47
|
+
# :nocov:
|
|
48
|
+
flash.now[:alert] = e.to_s
|
|
49
|
+
# @simple_user_notifier = @simple_user_notifier.decorate
|
|
50
|
+
render :new, status: :unprocessable_entity
|
|
51
|
+
# :nocov:
|
|
52
|
+
end
|
|
53
|
+
# rubocop:enable Metrics/MethodLength
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def atributos_permitidos
|
|
58
|
+
%i[
|
|
59
|
+
type message tooltip record_type record_id target subject
|
|
60
|
+
user_ids message_text
|
|
61
|
+
]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def atributos_para_buscar
|
|
65
|
+
%i[]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def atributos_para_listar
|
|
69
|
+
%i[message tooltip created_at notifications_count]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def atributos_para_mostrar
|
|
73
|
+
%i[tooltip]
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
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
|
|
@@ -29,4 +29,25 @@ class SimpleUserNotifier < ApplicationNotifier
|
|
|
29
29
|
# Add required params
|
|
30
30
|
#
|
|
31
31
|
required_param :message
|
|
32
|
+
|
|
33
|
+
attr_accessor :target, :user_ids
|
|
34
|
+
|
|
35
|
+
enumerize :target, in: { todos: 0, devs: 1, user_ids: 2 }
|
|
36
|
+
|
|
37
|
+
%i[message message_text tooltip subject].each do |field|
|
|
38
|
+
define_method :"#{field}" do
|
|
39
|
+
params[field]
|
|
40
|
+
end
|
|
41
|
+
define_method :"#{field}=" do |value|
|
|
42
|
+
params[field] = value
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.policy_class
|
|
47
|
+
ApplicationPolicy
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.decorator_class
|
|
51
|
+
PgEngine::BaseRecordDecorator
|
|
52
|
+
end
|
|
32
53
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
= pg_form_for @simple_user_notifier.decorate do |f|
|
|
2
|
+
- if params[:plain_text]
|
|
3
|
+
= link_to 'Change to rich text', url_for
|
|
4
|
+
= f.input :message, as: :text
|
|
5
|
+
- else
|
|
6
|
+
= link_to 'Change to plain text', url_for(plain_text: true)
|
|
7
|
+
= f.rich_text_area :message
|
|
8
|
+
= f.input :tooltip
|
|
9
|
+
/ = f.input :record_type
|
|
10
|
+
/ = f.input :record_id
|
|
11
|
+
- unless @simple_user_notifier.persisted?
|
|
12
|
+
= f.input :target
|
|
13
|
+
= f.input :user_ids, label: 'User emails'
|
|
14
|
+
= f.submit
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
- content_for :actions do
|
|
2
|
+
= @simple_user_notifier.destroy_link_redirect
|
|
3
|
+
.ms-1
|
|
4
|
+
= @simple_user_notifier.edit_link
|
|
5
|
+
|
|
6
|
+
table.table.table-borderless.table-sm.w-auto.mb-0.m-3
|
|
7
|
+
- atributos_para_mostrar.each do |att|
|
|
8
|
+
tr
|
|
9
|
+
th = @clase_modelo.human_attribute_name(att)
|
|
10
|
+
td = render InlineShowComponent.new(@simple_user_notifier.object, att)
|
|
11
|
+
tr
|
|
12
|
+
th = t('attributes.created_at')
|
|
13
|
+
td = @simple_user_notifier.created_at
|
|
14
|
+
tr
|
|
15
|
+
th = t('attributes.updated_at')
|
|
16
|
+
td = @simple_user_notifier.updated_at
|
|
17
|
+
|
|
18
|
+
.bg-secondary-subtle.p-4.mt-3.trix-content
|
|
19
|
+
= @simple_user_notifier.message.html_safe
|
|
20
|
+
|
|
21
|
+
div style="max-width: 30em"
|
|
22
|
+
table.table.table-sm
|
|
23
|
+
tr
|
|
24
|
+
th Destinatario
|
|
25
|
+
th Visto
|
|
26
|
+
- @simple_user_notifier.notifications.order('seen_at desc nulls last').each do |notification|
|
|
27
|
+
tr
|
|
28
|
+
td = notification.recipient
|
|
29
|
+
td = dmy_time notification.seen_at
|
data/pg_engine/config/routes.rb
CHANGED
|
@@ -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,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.
|
|
4
|
+
version: 7.6.17
|
|
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-
|
|
11
|
+
date: 2024-10-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -693,7 +693,7 @@ files:
|
|
|
693
693
|
- pg_engine/app/controllers/admin/accounts_controller.rb
|
|
694
694
|
- pg_engine/app/controllers/admin/email_logs_controller.rb
|
|
695
695
|
- pg_engine/app/controllers/admin/emails_controller.rb
|
|
696
|
-
- pg_engine/app/controllers/admin/
|
|
696
|
+
- pg_engine/app/controllers/admin/simple_user_notifiers_controller.rb
|
|
697
697
|
- pg_engine/app/controllers/admin/user_accounts_controller.rb
|
|
698
698
|
- pg_engine/app/controllers/admin/users_controller.rb
|
|
699
699
|
- pg_engine/app/controllers/concerns/pg_engine/require_tenant_set.rb
|
|
@@ -743,10 +743,10 @@ 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
|
|
749
|
-
- pg_engine/app/models/evento.rb
|
|
750
750
|
- pg_engine/app/models/mensaje_contacto.rb
|
|
751
751
|
- pg_engine/app/models/pg_engine/base_record.rb
|
|
752
752
|
- pg_engine/app/models/user.rb
|
|
@@ -776,8 +776,8 @@ files:
|
|
|
776
776
|
- pg_engine/app/views/admin/emails/_form.html.slim
|
|
777
777
|
- pg_engine/app/views/admin/emails/_send.html.slim
|
|
778
778
|
- pg_engine/app/views/admin/emails/show.html.slim
|
|
779
|
-
- pg_engine/app/views/admin/
|
|
780
|
-
- pg_engine/app/views/admin/
|
|
779
|
+
- pg_engine/app/views/admin/simple_user_notifiers/_form.html.slim
|
|
780
|
+
- pg_engine/app/views/admin/simple_user_notifiers/show.html.slim
|
|
781
781
|
- pg_engine/app/views/admin/user_accounts/_form.html.slim
|
|
782
782
|
- pg_engine/app/views/admin/user_accounts/_user_account.html.slim
|
|
783
783
|
- pg_engine/app/views/admin/user_accounts/edit.html.slim
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
module Admin
|
|
2
|
-
class EventosController < AdminController
|
|
3
|
-
layout 'pg_layout/containerized'
|
|
4
|
-
|
|
5
|
-
add_breadcrumb 'Eventos'
|
|
6
|
-
|
|
7
|
-
before_action do
|
|
8
|
-
@notifier_types = %w[
|
|
9
|
-
EmailUserNotifier
|
|
10
|
-
SimpleUserNotifier
|
|
11
|
-
]
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def index
|
|
15
|
-
@events = Noticed::Event.order(id: :desc)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# rubocop:disable Metrics/AbcSize
|
|
19
|
-
def new
|
|
20
|
-
@event = Evento.new(type: 'SimpleUserNotifier')
|
|
21
|
-
return if params[:event_id].blank?
|
|
22
|
-
|
|
23
|
-
reference = Noticed::Event.find(params[:event_id])
|
|
24
|
-
@event.type = reference.type
|
|
25
|
-
@event.message = reference.params[:message]
|
|
26
|
-
@event.message_text = reference.params[:message_text]
|
|
27
|
-
@event.tooltip = reference.params[:tooltip]
|
|
28
|
-
@event.subject = reference.params[:subject]
|
|
29
|
-
@event.record_type = reference.record_type
|
|
30
|
-
@event.record_id = reference.record_id
|
|
31
|
-
end
|
|
32
|
-
# rubocop:enable Metrics/AbcSize
|
|
33
|
-
|
|
34
|
-
# rubocop:disable Metrics/MethodLength
|
|
35
|
-
def create # rubocop:disable Metrics/AbcSize
|
|
36
|
-
@event = Evento.new(event_params)
|
|
37
|
-
# @event.message.save!
|
|
38
|
-
unless @event.valid?
|
|
39
|
-
render :new, status: :unprocessable_entity
|
|
40
|
-
return
|
|
41
|
-
end
|
|
42
|
-
json_params_for_event = {
|
|
43
|
-
record: @event.record,
|
|
44
|
-
message: @event.message,
|
|
45
|
-
message_text: @event.message_text,
|
|
46
|
-
tooltip: @event.tooltip,
|
|
47
|
-
subject: @event.subject
|
|
48
|
-
}
|
|
49
|
-
notifier_class = @event.type.constantize
|
|
50
|
-
notifier = notifier_class.with(json_params_for_event)
|
|
51
|
-
|
|
52
|
-
case @event.target
|
|
53
|
-
when 'todos'
|
|
54
|
-
notifier.deliver(User.all)
|
|
55
|
-
when 'devs'
|
|
56
|
-
notifier.deliver(User.where(developer: true))
|
|
57
|
-
when 'user_ids'
|
|
58
|
-
notifier.deliver(User.where(email: @event.user_ids.split(',')))
|
|
59
|
-
else
|
|
60
|
-
# :nocov:
|
|
61
|
-
'shouldnt happen'
|
|
62
|
-
# :nocov:
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
redirect_to admin_eventos_path
|
|
66
|
-
rescue StandardError => e
|
|
67
|
-
# :nocov:
|
|
68
|
-
flash.now[:alert] = e.to_s
|
|
69
|
-
render :new, status: :unprocessable_entity
|
|
70
|
-
# :nocov:
|
|
71
|
-
end
|
|
72
|
-
# rubocop:enable Metrics/MethodLength
|
|
73
|
-
|
|
74
|
-
private
|
|
75
|
-
|
|
76
|
-
def event_params
|
|
77
|
-
params.require(:evento).permit(
|
|
78
|
-
:type, :message, :tooltip, :record_type, :record_id, :target, :subject,
|
|
79
|
-
:user_ids, :message_text
|
|
80
|
-
)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class Evento
|
|
2
|
-
include ActiveModel::API
|
|
3
|
-
include ActionText::Attribute
|
|
4
|
-
extend Enumerize
|
|
5
|
-
|
|
6
|
-
attr_accessor :tooltip, :target, :message, :message_text, :type,
|
|
7
|
-
:record_type, :record_id,
|
|
8
|
-
:subject, :user_ids
|
|
9
|
-
|
|
10
|
-
validates :target, :type, :message, presence: true
|
|
11
|
-
|
|
12
|
-
enumerize :target, in: { todos: 0, devs: 1, user_ids: 2 }
|
|
13
|
-
|
|
14
|
-
validates :message_text, :subject, presence: true, if: lambda {
|
|
15
|
-
type == 'EmailUserNotifier'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
validates :user_ids, presence: true, if: lambda {
|
|
19
|
-
target == 'user_ids'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
def record
|
|
23
|
-
return if record_id.blank?
|
|
24
|
-
|
|
25
|
-
record_type.constantize.find(record_id)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
= pg_form_for @event, url: admin_eventos_path do |f|
|
|
2
|
-
= f.input :type, as: :select, collection: @notifier_types
|
|
3
|
-
- if params[:plain_text]
|
|
4
|
-
= link_to 'Change to rich text', url_for
|
|
5
|
-
= f.input :message, as: :text
|
|
6
|
-
- else
|
|
7
|
-
= link_to 'Change to plain text', url_for(plain_text: true)
|
|
8
|
-
= f.rich_text_area :message
|
|
9
|
-
= f.input :message_text, as: :text, hint: 'Solo para emails, para la plain/text part'
|
|
10
|
-
= f.input :tooltip
|
|
11
|
-
= f.input :subject
|
|
12
|
-
= f.input :record_type
|
|
13
|
-
= f.input :record_id
|
|
14
|
-
= f.input :target
|
|
15
|
-
= f.input :user_ids, label: 'User emails'
|
|
16
|
-
= f.submit
|