enviar la dirección de origen con el formulario de contacto

This commit is contained in:
f 2020-12-24 12:50:33 -03:00
parent 5900e63b07
commit f7828127d8
4 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -1,3 +1,6 @@
- if @params[:origin].present?
%p= @params[:origin]
- @params[:form].each do |field, value|
%p
%strong= @params[:form_definition].t(field) + ':'

View file

@ -1,3 +1,5 @@
- @params[:origin]
- @params[:form].each do |field, value|
= "#{@params[:form_definition].t(field)}: #{value}"
\