From 4fd4fa3a851ce139324963b0b4c1cd0a5dba39dc Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Mon, 21 Jan 2013 09:19:42 +0100 Subject: [PATCH] Fix email submission flow for suppliers --- app/models/supplier.rb | 12 +++++++++++- app/views/suppliers/confirmations/new.html.erb | 6 +++--- .../mailer/confirmation_instructions.html.slim | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/models/supplier.rb b/app/models/supplier.rb index a148bfcf..d9d4dcdf 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -97,11 +97,21 @@ class Supplier # Overwrite devise method for mail sending def self.confirm_by_token(confirmation_token) confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token) + send_creation_mail = confirmable.errors.empty? && !confirmable.confirmed? confirmable.confirm! if confirmable.persisted? - confirmable.send_creation_notifications if confirmable.errors.empty? + confirmable.send_creation_notifications if send_creation_mail confirmable end + # Send confirmation instructions by email + def send_confirmation_instructions + self.confirmation_token = nil if reconfirmation_required? + @reconfirmation_required = false + + @bypass_postpone = true and generate_confirmation_token! if self.confirmation_token.blank? + self.devise_mailer.confirmation_instructions(self).deliver + end + def send_creation_notifications SupplierMailer.creation(self).deliver end diff --git a/app/views/suppliers/confirmations/new.html.erb b/app/views/suppliers/confirmations/new.html.erb index 18d81b14..a995f57a 100644 --- a/app/views/suppliers/confirmations/new.html.erb +++ b/app/views/suppliers/confirmations/new.html.erb @@ -1,4 +1,4 @@ -

Resend confirmation instructions

+

Struur opnieuw bevestigingsinstructies

<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %> <%= devise_error_messages! %> @@ -6,7 +6,7 @@
<%= f.label :email %>
<%= f.email_field :email %>
-
<%= f.submit "Resend confirmation instructions" %>
+
<%= f.submit "Stuur opnieuw bevestigingsinstructies" %>
<% end %> -<%= render "links" %> \ No newline at end of file +<%= render "links" %> diff --git a/app/views/suppliers/mailer/confirmation_instructions.html.slim b/app/views/suppliers/mailer/confirmation_instructions.html.slim index 807dc09e..9566420d 100644 --- a/app/views/suppliers/mailer/confirmation_instructions.html.slim +++ b/app/views/suppliers/mailer/confirmation_instructions.html.slim @@ -1,7 +1,7 @@ h3 "Welkom bij Qwaiter #{@resource.email}!" p | - Je hebt een account aangevraag bij Qwaiter. Als dit niet de bedoeling is kan je deze email negeren. - Om je account te activeren moet je op de bevestigingslink hieronder klikken: + Je hebt een account aangevraag bij Qwaiter of wil een wijziging doorvoeren waarvoor bevestiging nodig is. Als dit niet de bedoeling is kan je deze email negeren. + Om je account te activeren of de aangevraagde wijziging door te voeren moet je op de bevestigingslink hieronder klikken: p= link_to 'Bevestig mijn Qwaiter account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token)