From 57d0fa0c8ef823cb7fad23b26813c34a21876320 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 2 Oct 2018 15:16:56 -0300 Subject: [PATCH] enviar mails de confirmacion con formato correcto --- .env.example | 1 + app/controllers/invitadxs_controller.rb | 3 ++- app/mailers/invitadx_mailer.rb | 2 +- app/views/invitadxs/show.haml | 3 ++- config/environments/production.rb | 2 +- config/locales/en.yml | 7 +++++++ config/locales/es.yml | 7 +++++++ config/routes.rb | 7 ++++--- 8 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 9c5d13f..4bf6b30 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ SECRET_KEY_BASE= IMAP_SERVER= +DEFAULT_FROM= diff --git a/app/controllers/invitadxs_controller.rb b/app/controllers/invitadxs_controller.rb index 3e2854f..404130d 100644 --- a/app/controllers/invitadxs_controller.rb +++ b/app/controllers/invitadxs_controller.rb @@ -22,13 +22,14 @@ class InvitadxsController < ApplicationController if @invitadx.save InvitadxMailer.with(site: @site, invitadx: @invitadx).confirmation_required.deliver - redirect_to invitadx_path(@invitadx) + redirect_to site_invitadx_path(@site, @invitadx) else render 'new' end end def show + @site = Site.find(params[:site_id]) @has_cover = true @invitadx = Invitadx.find(params[:id]) end diff --git a/app/mailers/invitadx_mailer.rb b/app/mailers/invitadx_mailer.rb index 45adb10..ee94f5c 100644 --- a/app/mailers/invitadx_mailer.rb +++ b/app/mailers/invitadx_mailer.rb @@ -2,6 +2,6 @@ class InvitadxMailer < ApplicationMailer def confirmation_required @invitadx = params[:invitadx] @site = params[:site] - mail to: @invitadx.email, subject: t('.subject') + mail from: "#{@site.config.dig('title')} <#{ENV.fetch('DEFAULT_FROM', 'sutty@kefir.red')}>", to: @invitadx.email, subject: t('.subject') end end diff --git a/app/views/invitadxs/show.haml b/app/views/invitadxs/show.haml index 7a01aac..e1d4728 100644 --- a/app/views/invitadxs/show.haml +++ b/app/views/invitadxs/show.haml @@ -1,3 +1,4 @@ .row.align-items-center.justify-content-center.full-height .col-md-6.align-self-center - = t('.confirmation_sent') + .alert{role: 'alert', class: "alert-success"} + = t('.confirmation_sent') diff --git a/config/environments/production.rb b/config/environments/production.rb index 5d3ad7d..7474a05 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -90,7 +90,7 @@ Rails.application.configure do config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :sendmail - config.action_mailer.default_options = { from: 'sutty@kefir.red' } + config.action_mailer.default_options = { from: ENV.fetch('DEFAULT_FROM', 'sutty@kefir.red') } config.middleware.use ExceptionNotification::Rack, email: { diff --git a/config/locales/en.yml b/config/locales/en.yml index 1b45dd3..e83da36 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -15,6 +15,11 @@ en: reorder: "We're sorry, we couldn't reorder the articles" disordered: "The posts are disordered, this will prevent you from reordering them!" disordered_button: 'Reorder!' + invitadx_mailer: + confirmation_required: + subject: "Confirm your e-mail address" + hi: "Hi!" + body: "Please open this link to confirm your e-mail address." invitadxs: index: title: Guests @@ -25,6 +30,8 @@ en: submit: Register confirmation: confirmed: 'Your account is confirmed, please log in to continue' + show: + confirmation_sent: "We've sent a confirmation link to your e-mail address. Please open that link to continue." info: posts: reorder: "The articles have been reordered!" diff --git a/config/locales/es.yml b/config/locales/es.yml index 859a113..8bde2fb 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -15,6 +15,11 @@ es: reorder: "Lo sentimos, no pudimos reordenar los artículos." disordered: 'Los artículos no tienen número de orden, esto impedirá que los puedas reordenar' disordered_button: '¡Reordenar!' + invitadx_mailer: + confirmation_required: + subject: "Confirma tu dirección de correo" + hi: "¡Hola!" + body: "Por favor abre esta dirección para confirmar tu cuenta de correo." invitadxs: index: title: Invitadxs @@ -25,6 +30,8 @@ es: submit: Registrarme confirmation: confirmed: 'Tu cuenta está confirmada, ahora puedes ingresar' + show: + confirmation_sent: "Te hemos enviado un correo de confirmación a tu casilla, por favor confirma tu cuenta antes de continuar." info: posts: reorder: "¡Los artículos fueron reordenados!" diff --git a/config/routes.rb b/config/routes.rb index 3c9b784..1ba035f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,13 +9,14 @@ Rails.application.routes.draw do get '/sites/:site_id/public/:type/:basename', to: 'sites#send_public_file' - resources :invitadxs, only: [:create, :show] do - end + # XXX Mantenemos solo esta ruta acá porque form_for no reconoce @site + # como un objeto válido + resources :invitadxs, only: [:create] resources :sites, only: [:index, :show], constraints: { site_id: /[^\/]+/, id: /[^\/]+/ } do resources :posts resources :templates - resources :invitadxs, only: [:index, :new] do + resources :invitadxs, only: [:index, :new, :show] do get :confirmation, to: 'invitadxs#confirmation' end get :'invitadxs/login/new', to: 'login#new'