pg_rails 7.0.8.pre.alpha.80 → 7.0.8.pre.alpha.82

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: 60b0661bbe95efdd5b745287b125b28ae41ed84671ad954d15d012f93749620a
4
- data.tar.gz: 0ebe72c73adbc1fe921b93e2a6743d2e364093e73d5b2076735eaff9f7dce021
3
+ metadata.gz: f155f16783603b8b6acd943855ce4d4996d92722235ec8eea4fe9cf82dd6efb0
4
+ data.tar.gz: 4403492bc1eaeecb807dd9bab487047b89681007100baf5e6758271a8967f163
5
5
  SHA512:
6
- metadata.gz: a647a66a04033744632a1e42bbd79db9c8e2f958e90592a4bd763d868a63d140e3527386e3bad7cef441c9053ddd41ac3ffecabcd0046df7fd1d52f96ddd2500
7
- data.tar.gz: 477837a7b13838e1283f88a871c61f4670642e72a7c83ad885160c53e0550b3e63f1e74a8cda4897e87b51262723d87848c490662ca2dd06dac29f4cce59e041
6
+ metadata.gz: 97f5a71981109ce5a8dac87ce5db0184e5c21fc906adc0863ca916e2b8868e5dc013ea46a924e42780b49e9d658faf32a8b5c34bcdf272edd549f848a4ad9918
7
+ data.tar.gz: 69dc1acfe7f80c080c4f0263f1904f9ceaff511da31a24e37ba5f77fa6e76fb4888af45313c7c41ab58b3fe3697cdaf46306c28c426bcac91e0badc84ad4aa69
@@ -265,7 +265,7 @@ export default class extends Controller {
265
265
  this.buscando()
266
266
  }, 200)
267
267
  // console.log(`setTimeOut ${timerBuscandoId}`)
268
- document.addEventListener('turbo:before-stream-render', (i) => {
268
+ document.addEventListener('turbo:before-stream-render', () => {
269
269
  // console.log(`clear before stream render ${timerBuscandoId}`)
270
270
  clearTimeout(timerBuscandoId)
271
271
  }, { once: true })
@@ -290,6 +290,7 @@ export default class extends Controller {
290
290
  }
291
291
 
292
292
  completarCampo (target) {
293
+ // FIXME: savedInputState = null
293
294
  const textField = this.element.querySelector('input[type=text]')
294
295
  const hiddenField = this.element.querySelector('input[type=hidden]')
295
296
 
@@ -92,7 +92,6 @@ module PgEngine
92
92
  if params[:asociable]
93
93
  format.turbo_stream do
94
94
  render turbo_stream:
95
- # rubocop:disable Rails/SkipsModelValidations
96
95
  turbo_stream.update_all('.modal.show .pg-associable-form', <<~HTML
97
96
  <div data-modal-target="response" data-response='#{object.decorate.to_json}'></div>
98
97
  HTML
@@ -91,7 +91,7 @@ module PgEngine
91
91
 
92
92
  protected
93
93
 
94
- def not_authorized
94
+ def not_authorized(_arg_required_for_active_admin)
95
95
  respond_to do |format|
96
96
  format.json do
97
97
  render json: { error: 'Acceso no autorizado' },
@@ -6,7 +6,6 @@ module PgEngine
6
6
 
7
7
  def render_turbo_stream_title
8
8
  title = [breadcrumbs.last&.name, I18n.t('app_name')].compact.join(' - ')
9
- # rubocop:disable Rails/SkipsModelValidations
10
9
  turbo_stream.update_all 'title', title
11
10
  # rubocop:enable Rails/SkipsModelValidations
12
11
  end
@@ -2,34 +2,38 @@ module PgEngine
2
2
  class BaseMailer < ActionMailer::Base # rubocop:disable Rails/ApplicationMailer
3
3
  class MailNotDelivered < StandardError; end
4
4
 
5
- before_action { @email = params[:email] }
6
-
7
- default from: -> { email_address_with_name(@email.from_address, @email.from_name) },
8
- reply_to: -> { @email.reply_to },
9
- subject: -> { @email.subject },
10
- to: -> { @email.to }
5
+ before_action { @email_object = params[:email_object] }
6
+
7
+ default from: lambda { |_mailer|
8
+ if @email_object.present?
9
+ email_address_with_name(@email_object.from_address, @email_object.from_name)
10
+ else
11
+ email_address_with_name(ENV.fetch('DEFAULT_MAIL_FROM'), ENV.fetch('DEFAULT_MAIL_FROM_NAME'))
12
+ end
13
+ },
14
+ reply_to: ->(_mailer) { @email_object.reply_to if @email_object.present? },
15
+ subject: ->(_mailer) { @email_object.subject if @email_object.present? },
16
+ to: ->(_mailer) { @email_object.to if @email_object.present? }
11
17
 
12
18
  layout 'pg_layout/mailer'
13
19
 
14
20
  # default delivery_method: :smtp
15
21
 
16
22
  rescue_from StandardError do |err|
17
- pg_warn err, :error
18
- if @email.present?
19
- @email.update_columns(status: :failed, status_detail: err.to_s) # rubocop:disable Rails/SkipsModelValidations
20
- end
23
+ pg_err err
24
+ @email_object.update_columns(status: :failed, status_detail: err.to_s) if @email_object.present?
21
25
  end
22
26
 
23
27
  protected
24
28
 
25
29
  def mail(*args)
26
- @footer_href = root_url(m: @email.hashid)
30
+ @footer_href = root_url(m: @email_object&.hashid)
27
31
  super(*args).tap do |message|
28
32
  # message.mailgun_options = {
29
33
  # 'tag' => email.tags,
30
34
  # 'tracking-opens' => true
31
35
  # }
32
- message['email'] = @email
36
+ message['email_object'] = @email_object if @email_object.present?
33
37
  end
34
38
  end
35
39
  end
@@ -36,6 +36,8 @@ class Email < ApplicationRecord
36
36
  include Hashid::Rails
37
37
  audited
38
38
 
39
+ attr_accessor :require_body_input
40
+
39
41
  has_one_attached :encoded_eml
40
42
 
41
43
  belongs_to :associated, polymorphic: true, optional: true
@@ -61,6 +63,9 @@ class Email < ApplicationRecord
61
63
  validates :from_name, length: { within: 0..80 }
62
64
  validates :to, length: { within: 3..200 }
63
65
 
66
+ validates :body_input, length: { minimum: 10 }, if: -> { require_body_input }
67
+ validates :body_input, presence: true, if: -> { require_body_input }
68
+
64
69
  validates :from_name, :subject, :to,
65
70
  format: { with: /\A[^\n<>&]*\z/, message: 'contiene caracteres inválidos' }
66
71
 
@@ -105,7 +105,7 @@ ActiveAdmin.setup do |config|
105
105
  # because, by default, user gets redirected to Dashboard. If user
106
106
  # doesn't have access to Dashboard, he'll end up in a redirect loop.
107
107
  # Method provided here should be defined in application_controller.rb.
108
- # config.on_unauthorized_access = :access_denied
108
+ config.on_unauthorized_access = :not_authorized
109
109
 
110
110
  # == Current User
111
111
  #
@@ -24,13 +24,13 @@ Devise.setup do |config|
24
24
  # Configure the e-mail address which will be shown in Devise::Mailer,
25
25
  # note that it will be overwritten if you use your own mailer class
26
26
  # with default "from" parameter.
27
- config.mailer_sender = ENV.fetch('DEFAULT_MAIL_FROM', 'please-change-me-at-config-initializers-devise@example.com')
27
+ # config.mailer_sender = ""
28
28
 
29
29
  # Configure the class responsible to send e-mails.
30
30
  # config.mailer = 'Devise::Mailer'
31
31
 
32
32
  # Configure the parent class responsible to send e-mails.
33
- # config.parent_mailer = 'ActionMailer::Base'
33
+ config.parent_mailer = 'ApplicationMailer'
34
34
 
35
35
  # ==> ORM configuration
36
36
  # Load and configure the ORM. Supports :active_record (default) and
@@ -65,6 +65,7 @@ es:
65
65
  timeout: ''
66
66
  unauthenticated: ''
67
67
  registrations:
68
+ signed_up_but_unconfirmed: Te enviamos un correo electrónico con instrucciones para confirmar tu cuenta.
68
69
  new:
69
70
  sign_up: Crear una cuenta
70
71
  passwords:
@@ -77,6 +78,28 @@ es:
77
78
  sign_up: Crear una cuenta
78
79
  forgot_your_password: ¿Olvidaste tu contraseña?
79
80
  didn_t_receive_confirmation_instructions: ¿No recibiste las instrucciones para confirmar tu cuenta?
81
+ mailer:
82
+ confirmation_instructions:
83
+ action: Confirmá tu cuenta
84
+ greeting: "Hola %{recipient}"
85
+ instruction: 'por favor, confirmá tu cuenta haciendo click en el siguiente enlace:'
86
+ subject: Confirmación de cuenta
87
+ email_changed:
88
+ greeting: "Hola %{recipient}"
89
+ message: Estamos contactando contigo para notificarte que tu email ha sido cambiado a %{email}.
90
+ message_unconfirmed: Nos estamos contactando contigo para notificarte que tu correo se está cambiando a %{email}.
91
+ subject: Email cambiado
92
+ password_change:
93
+ greeting: "Hola %{recipient}"
94
+ message: Lo estamos contactando para notificarle que su contraseña ha sido cambiada.
95
+ subject: Contraseña cambiada
96
+ reset_password_instructions:
97
+ action: Cambiar mi contraseña
98
+ greeting: "Hola %{recipient}"
99
+ instruction: "Para cambiar tu contraseña ingresá al siguiente link:"
100
+ instruction_2: Si no solicitaste cambiar tu contraseña, podés ignorar este correo.
101
+ instruction_3: Tu contraseña no será cambiada hasta que accedas al link y crees una nueva.
102
+ subject: Recuperación de contraseña
80
103
  activerecord:
81
104
  attributes:
82
105
  user:
@@ -6,18 +6,18 @@ module PgEngine
6
6
  message_id = message.message_id
7
7
  mailer = message.delivery_handler.to_s
8
8
  status = get_status(message)
9
- if message['email'].present?
10
- email = message['email'].unparsed_value
11
- email.update_columns(message_id:, mailer:, status:) # rubocop:disable Rails/SkipsModelValidations
9
+ if message['email_object'].present?
10
+ email_object = message['email_object'].unparsed_value
11
+ email_object.update_columns(message_id:, mailer:, status:)
12
12
  else
13
13
  to = [message.to].flatten.join(', ')
14
14
  from = [message.from].flatten.join(', ')
15
- email = Email.create!(message_id:, subject: message.subject, to:, mailer:, status:, from_address: from,
16
- from_name: '')
15
+ email_object = Email.create!(message_id:, subject: message.subject, to:, mailer:, status:, from_address: from,
16
+ from_name: '')
17
17
  end
18
- email.encoded_eml.attach({ io: StringIO.new(message.encoded), filename: "email-#{email.id}.eml" })
18
+ email_object.encoded_eml.attach({ io: StringIO.new(message.encoded), filename: "email-#{email_object.id}.eml" })
19
19
  rescue StandardError => e
20
- pg_warn e, :error
20
+ pg_err e
21
21
  end
22
22
 
23
23
  def self.get_status(message)
@@ -20,6 +20,9 @@ module PgEngine
20
20
  end
21
21
 
22
22
  initializer 'configurar_pg_rails' do
23
+ # Ensure required env variables are set
24
+ ENV.fetch('DEFAULT_MAIL_FROM')
25
+ ENV.fetch('DEFAULT_MAIL_FROM_NAME')
23
26
  # SimpleForm
24
27
  require "#{PgEngine::Engine.root}/config/simple_form/simple_form"
25
28
  require "#{PgEngine::Engine.root}/config/simple_form/simple_form_bootstrap"
@@ -68,8 +68,8 @@ describe PgEngine::Resource do
68
68
  let(:param) { :categoria_de_cosa }
69
69
 
70
70
  before do
71
- cosa_pri.categoria_de_cosa.update_column(:nombre, 'a') # rubocop:disable Rails/SkipsModelValidations
72
- cosa_ult.categoria_de_cosa.update_column(:nombre, 'z') # rubocop:disable Rails/SkipsModelValidations
71
+ cosa_pri.categoria_de_cosa.update_column(:nombre, 'a')
72
+ cosa_ult.categoria_de_cosa.update_column(:nombre, 'z')
73
73
  end
74
74
 
75
75
  context 'si es asc' do
@@ -23,7 +23,7 @@ describe 'Al Registrarse', :js do
23
23
  fill_in 'user_password', with: 'admin123'
24
24
  fill_in 'user_password_confirmation', with: 'admin123'
25
25
  instance_exec('input[type=submit]', &find_scroll).click
26
- expect(page).to have_text('Se ha enviado un mensaje con un enlace')
26
+ expect(page).to have_text('Te enviamos un correo electrónico con instrucciones')
27
27
  end
28
28
  end
29
29
 
@@ -0,0 +1,13 @@
1
+ # Preview all emails at http://localhost:3000/rails/mailers/cliente
2
+ class DevisePreview < ActionMailer::Preview
3
+ # Preview this email at http://localhost:3000/rails/mailers/cliente/comprobante_recibido
4
+ def confirmation_instructions
5
+ # ClienteMailer.comprobante_recibido(VComprobante.find(params[:]))
6
+ Devise::Mailer.confirmation_instructions(User.first, 'TOKENN')
7
+ end
8
+
9
+ def reset_password_instructions
10
+ # ClienteMailer.comprobante_recibido(VComprobante.find(params[:]))
11
+ Devise::Mailer.reset_password_instructions(User.first, 'TOKENN')
12
+ end
13
+ end
@@ -1,4 +1,4 @@
1
- <p><%= t('.greeting', recipient: @email) %></p>
1
+ <p><%= t('.greeting', recipient: @resource.nombre) %></p>
2
2
 
3
3
  <p><%= t('.instruction') %></p>
4
4
 
@@ -1,4 +1,4 @@
1
- <p><%= t('.greeting', recipient: @email) %></p>
1
+ <p><%= t('.greeting', recipient: @resource.nombre) %></p>
2
2
 
3
3
  <% if @resource.try(:unconfirmed_email?) %>
4
4
  <p><%= t('.message_unconfirmed', email: @resource.unconfirmed_email) %></p>
@@ -1,3 +1,3 @@
1
- <p><%= t('.greeting', recipient: @resource.email) %></p>
1
+ <p><%= t('.greeting', recipient: @resource.nombre) %></p>
2
2
 
3
3
  <p><%= t('.message') %></p>
@@ -1,4 +1,4 @@
1
- <p><%= t('.greeting', recipient: @resource.email) %></p>
1
+ <p><%= t('.greeting', recipient: @resource.nombre) %></p>
2
2
 
3
3
  <p><%= t('.instruction') %></p>
4
4
 
@@ -1,4 +1,4 @@
1
- <p><%= t('.greeting', recipient: @resource.email) %></p>
1
+ <p><%= t('.greeting', recipient: @resource.nombre) %></p>
2
2
 
3
3
  <p><%= t('.message') %></p>
4
4
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.80'
4
+ VERSION = '7.0.8-alpha.82'
5
5
  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.80
4
+ version: 7.0.8.pre.alpha.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
@@ -1084,6 +1084,7 @@ files:
1084
1084
  - pg_engine/spec/lib/pg_engine/mailgun/log_sync_spec.rb
1085
1085
  - pg_engine/spec/lib/pg_engine/utils/pg_engine/pg_logger_spec.rb
1086
1086
  - pg_engine/spec/lib/pg_form_builder_spec.rb
1087
+ - pg_engine/spec/mailers/previews/devise_preview.rb
1087
1088
  - pg_engine/spec/models/account_spec.rb
1088
1089
  - pg_engine/spec/models/email_spec.rb
1089
1090
  - pg_engine/spec/models/mensaje_contacto_spec.rb