Confirmation email when creating enterprise

This commit is contained in:
Rob Harrington
2014-10-15 10:48:05 +11:00
parent b8b19368df
commit 908c242d36
5 changed files with 22 additions and 1 deletions

View File

@@ -1,10 +1,18 @@
require 'devise/mailers/helpers'
class EnterpriseMailer < Spree::BaseMailer
include Devise::Mailers::Helpers
def creation_confirmation(enterprise)
find_enterprise(enterprise)
subject = "#{@enterprise.name} is now on #{Spree::Config[:site_name]}"
mail(:to => @enterprise.owner.email, :from => from_address, :subject => subject)
end
def confirmation_instructions(record, token, opts={})
@token = token
devise_mail(record, :confirmation_instructions, opts)
end
private
def find_enterprise(enterprise)
@enterprise = enterprise.is_a?(Enterprise) ? enterprise : Enterprise.find(enterprise)

View File

@@ -1,5 +1,5 @@
Spree::UserMailer.class_eval do
def signup_confirmation(user)
@user = user
mail(:to => user.email, :from => from_address,

View File

@@ -262,6 +262,12 @@ class Enterprise < ActiveRecord::Base
select('DISTINCT spree_taxons.*')
end
protected
def devise_mailer
EnterpriseMailer
end
private
def send_creation_email

View File

@@ -0,0 +1,5 @@
%p= "Welcome #{@resource.contact}!"
%p= "You can confirm this email address for #{@resource.name} using the link below:"
%p= link_to 'Confirm this email address', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token)

View File

@@ -35,6 +35,8 @@ Openfoodnetwork::Application.routes.draw do
end
end
devise_for :enterprise
namespace :admin do
resources :order_cycles do
post :bulk_update, on: :collection, as: :bulk_update