From 1cc57df126ceb8d7a5323630457e3de1767833af Mon Sep 17 00:00:00 2001 From: f Date: Wed, 10 Jul 2019 19:30:32 -0300 Subject: [PATCH] =?UTF-8?q?enviar=20el=20nombre=20del=20sitio=20en=20la=20?= =?UTF-8?q?invitaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .rubocop.yml | 2 +- app/controllers/usuaries_controller.rb | 11 +++++++++-- app/views/devise/mailer/invitation_instructions.haml | 3 ++- .../devise/mailer/invitation_instructions.text.haml | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1e38f2f..a42adca 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -32,7 +32,7 @@ Metrics/MethodLength: - 'app/controllers/invitadxs_controller.rb' - 'app/controllers/i18n_controller.rb' - 'app/controllers/collaborations_controller.rb' - + - 'app/controllers/usuaries_controller.rb' Metrics/BlockLength: Exclude: diff --git a/app/controllers/usuaries_controller.rb b/app/controllers/usuaries_controller.rb index 7ed088e..529d8be 100644 --- a/app/controllers/usuaries_controller.rb +++ b/app/controllers/usuaries_controller.rb @@ -82,13 +82,20 @@ class UsuariesController < ApplicationController # TODO: Enviar invitación igual! Podemos no usar el Mailer de # DeviseInvitations y usar uno propio que contenga texto y se # envíe de todas formas. - usuarie = Usuarie.invite! email: invitacion.address + usuarie = Usuarie.invite! email: invitacion.address, + skip_invitation: true # No invitar al sitio si ya estaba en la lista! - next if @site.invitade?(usuarie) || @site.usuarie?(usuarie) + # + # XXX: En este caso no estamos enviando ninguna invitación + next if usuarie.sites.exists? @site.id @site.roles << Rol.create(usuarie: usuarie, site: @site, temporal: true, rol: invited_as) + + # Invitamos después de crear el rol para que el correo de + # invitación pueda recibir el sitio. + usuarie.deliver_invitation end redirect_to site_usuaries_path(@site) diff --git a/app/views/devise/mailer/invitation_instructions.haml b/app/views/devise/mailer/invitation_instructions.haml index f2f4221..7455123 100644 --- a/app/views/devise/mailer/invitation_instructions.haml +++ b/app/views/devise/mailer/invitation_instructions.haml @@ -1,5 +1,6 @@ +- binding.pry %p= t("devise.mailer.invitation_instructions.hello", email: @resource.email) -%p= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) +%p= t("devise.mailer.invitation_instructions.someone_invited_you", url: @resource.sites.first.name) %p= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, invitation_token: @token) - if @resource.invitation_due_at %p= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) diff --git a/app/views/devise/mailer/invitation_instructions.text.haml b/app/views/devise/mailer/invitation_instructions.text.haml index a9d23d3..e45dcef 100644 --- a/app/views/devise/mailer/invitation_instructions.text.haml +++ b/app/views/devise/mailer/invitation_instructions.text.haml @@ -1,5 +1,5 @@ = t("devise.mailer.invitation_instructions.hello", email: @resource.email) -= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) += t("devise.mailer.invitation_instructions.someone_invited_you", url: @resource.sites.first.name) = accept_invitation_url(@resource, invitation_token: @token) - if @resource.invitation_due_at = t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format'))