From f7828127d8ac080a3591fb4c02b9f80da457e047 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 24 Dec 2020 12:50:33 -0300 Subject: [PATCH] =?UTF-8?q?enviar=20la=20direcci=C3=B3n=20de=20origen=20co?= =?UTF-8?q?n=20el=20formulario=20de=20contacto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/contact_controller.rb | 3 ++- app/jobs/contact_job.rb | 7 ++++--- app/views/contact_mailer/notify_usuaries.html.haml | 3 +++ app/views/contact_mailer/notify_usuaries.text.haml | 2 ++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/contact_controller.rb b/app/controllers/api/v1/contact_controller.rb index 8b592a5a..deacf4a7 100644 --- a/app/controllers/api/v1/contact_controller.rb +++ b/app/controllers/api/v1/contact_controller.rb @@ -20,7 +20,8 @@ module Api # El sitio nos dice a dónde tenemos que ir. ContactJob.perform_async site.id, params[:form], - contact_params.to_h.symbolize_keys + contact_params.to_h.symbolize_keys, + params[:redirect] redirect_to params[:redirect] || origin.to_s end diff --git a/app/jobs/contact_job.rb b/app/jobs/contact_job.rb index 63c45467..c15d7eee 100644 --- a/app/jobs/contact_job.rb +++ b/app/jobs/contact_job.rb @@ -5,13 +5,13 @@ class ContactJob < ApplicationJob # @param [Integer] # @param [String] # @param [Hash] - def perform(site_id, form_name, form) + def perform(site_id, form_name, form, origin = nil) # Retrocompabilidad al actualizar a 2.7.1 # @see ApplicationJob#site @params = { site_id: site_id } # Sanitizar los valores - form.keys.each do |key| + form.each_key do |key| form[key] = ActionController::Base.helpers.sanitize form[key] end @@ -24,7 +24,8 @@ class ContactJob < ApplicationJob ContactMailer.with(form_name: form_name, form: form, site_id: site_id, - usuaries_emails: u) + usuaries_emails: u, + origin: origin) .notify_usuaries.deliver_now end end diff --git a/app/views/contact_mailer/notify_usuaries.html.haml b/app/views/contact_mailer/notify_usuaries.html.haml index 792660b7..f3c3903b 100644 --- a/app/views/contact_mailer/notify_usuaries.html.haml +++ b/app/views/contact_mailer/notify_usuaries.html.haml @@ -1,3 +1,6 @@ +- if @params[:origin].present? + %p= @params[:origin] + - @params[:form].each do |field, value| %p %strong= @params[:form_definition].t(field) + ':' diff --git a/app/views/contact_mailer/notify_usuaries.text.haml b/app/views/contact_mailer/notify_usuaries.text.haml index 1c440de8..8165a2e5 100644 --- a/app/views/contact_mailer/notify_usuaries.text.haml +++ b/app/views/contact_mailer/notify_usuaries.text.haml @@ -1,3 +1,5 @@ +- @params[:origin] + - @params[:form].each do |field, value| = "#{@params[:form_definition].t(field)}: #{value}" \