Added mailer to notify on new user

This commit is contained in:
Will Bradley 2013-02-01 04:44:05 -07:00
parent 50171effad
commit 1239d6682b
10 changed files with 68 additions and 15 deletions

View File

@ -0,0 +1,13 @@
class UserMailer < ActionMailer::Base
default :from => "wiki@heatsynclabs.org"
def new_user_email(user)
@user = user
@url = "http://members.heatsynclabs.org"
@admins = User.where(:name => "Will Bradley")
@admins.each do |admin|
mail(:to => admin.email, :subject => "New HeatSync Member")
end
end
end

View File

@ -15,6 +15,9 @@ class User < ActiveRecord::Base
has_many :user_certifications has_many :user_certifications
has_many :certifications, :through => :user_certifications has_many :certifications, :through => :user_certifications
after_create :send_new_user_email
def member_status def member_status
output = "" output = ""
@ -45,4 +48,12 @@ class User < ActiveRecord::Base
return output return output
end end
private
def send_new_user_email
Rails.logger.info UserMailer.new_user_email(self).deliver
end
end end

View File

@ -8,7 +8,7 @@ Thanks again, and happy hacking!</p>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => html) do |f| %> <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => html) do |f| %>
<div class="field"> <div class="field">
<%= f.label :name %><br /> <%= f.label :name, "Full Name" %><br />
<%= f.text_field :name %> <%= f.text_field :name %>
</div> </div>
@ -22,7 +22,7 @@ Thanks again, and happy hacking!</p>
<%= f.text_field :phone %> <%= f.text_field :phone %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :emergency_name, "Emergency contact" %><br /> <%= f.label :emergency_name, "Emergency Contact Name" %><br />
<%= f.text_field :emergency_name %> <%= f.text_field :emergency_name %>
</div> </div>
<div class="field"> <div class="field">
@ -41,22 +41,22 @@ Thanks again, and happy hacking!</p>
<%= render :partial => "/users/payment_methods", :locals => { :g => f } %> <%= render :partial => "/users/payment_methods", :locals => { :g => f } %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :current_skills %><br /> <%= f.label :current_skills, "What skills, knowledge and experience do you bring to the community?" %><br />
<%= f.text_area :current_skills %> <%= f.text_area :current_skills %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :desired_skills %><br /> <%= f.label :desired_skills, "What skills, knowledge and experiences are you looking for in HeatSync?" %><br />
<%= f.text_area :desired_skills %> <%= f.text_area :desired_skills %>
</div> </div>
<div><%= f.label :password %><br /> <div><%= f.label :password %><% if params[:action]!='new' %> <em>(Only if you want to change your password)</em><% end %><br />
<%= f.password_field :password %></div> <%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><br /> <div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div> <%= f.password_field :password_confirmation %></div>
<% if params[:action]!='new' %> <% if params[:action]!='new' %>
<div><%= f.label :current_password %><br /> <div><%= f.label :current_password, "Type Your Current Password" %> <em>(For your account's security)</em><br />
<%= f.password_field :current_password %></div> <%= f.password_field :current_password %></div>
<% end %> <% end %>

View File

@ -1,4 +1,4 @@
<h2>Sign up</h2> <h2>Membership Application</h2>
<%= devise_error_messages! %> <%= devise_error_messages! %>

View File

@ -22,7 +22,7 @@
<% if user_signed_in? then %><%= link_to 'Profile', edit_user_registration_path %><% end %> <% if user_signed_in? then %><%= link_to 'Profile', edit_user_registration_path %><% end %>
<%= link_to 'Logout', destroy_user_session_path, :method => :delete if user_signed_in? %> <%= link_to 'Logout', destroy_user_session_path, :method => :delete if user_signed_in? %>
<%= link_to 'Login', new_user_session_path unless user_signed_in? %> <%= link_to 'Login', new_user_session_path unless user_signed_in? %>
<%= link_to 'Become a Member', new_user_registration_path unless user_signed_in? %> <%= link_to 'Membership Application', new_user_registration_path unless user_signed_in? %>
</div> </div>
<div id="content"> <div id="content">
<p class="notice"><%= raw(notice) %></p> <p class="notice"><%= raw(notice) %></p>

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h2><%= @user.name %> just signed up.</h2>
<p>
Please contact them at <%= @user.email %><%= " or "+@user.phone.to_s unless @user.phone.blank? %> to set up a
new user orientation, waiver, welcome, payment help, etc.<br/>
</p>
<p>
To login to the site, just follow this link: <%= @url %>
</p>
</body>
</html>

View File

@ -0,0 +1,6 @@
<%= @user.name %> just signed up.
---
Please contact them at <%= @user.email %><%= " or "+@user.phone.to_s unless @user.phone.blank? %> to set up a
new user orientation, waiver, welcome, payment help, etc.
To login to the site, just follow this link: <%= @url %>

View File

@ -17,7 +17,7 @@
<% end %> <% end %>
<div class="field"> <div class="field">
<%= f.label :name %><br /> <%= f.label :name, "Full Name" %><br />
<%= f.text_field :name %> <%= f.text_field :name %>
</div> </div>
<div class="field"> <div class="field">
@ -60,7 +60,7 @@
</div> </div>
<div class="field"> <div class="field">
<%= f.label :member_level, "Desired Member Level" %><br /> <%= f.label :member_level, "Desired Member Level" %><br />
<%= f.select :member_level, [[nil],["None",0],["Unable",1],["Volunteer",10],["Associate",25],["Basic",50],["Plus",100]] %> <%= f.select :member_level, [[nil],["None",0],["Unable",1],["Volunteer",10],["Associate ($25)",25],["Basic ($50)",50],["Plus ($100)",100]] %>
</div> </div>
<div class="field"> <div class="field">
<%= render :partial => "/users/payment_methods", :locals => { :g => f } %> <%= render :partial => "/users/payment_methods", :locals => { :g => f } %>
@ -70,11 +70,11 @@
<%= f.text_field :phone %> <%= f.text_field :phone %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :current_skills %><br /> <%= f.label :current_skills, "What skills, knowledge and experience do you bring to the community?" %><br />
<%= f.text_area :current_skills %> <%= f.text_area :current_skills %>
</div> </div>
<div class="field"> <div class="field">
<%= f.label :desired_skills %><br /> <%= f.label :desired_skills, "What skills, knowledge and experiences are you looking for in HeatSync?" %><br />
<%= f.text_area :desired_skills %> <%= f.text_area :desired_skills %>
</div> </div>
<div class="field"> <div class="field">

View File

@ -1,13 +1,13 @@
<% @payment_methods = [[nil],["PayPal"],["Dwolla"],["Bill Pay","BillPay"],["Check"],["Cash"],["Other"]] <% @payment_methods = [[nil],["PayPal"],["Dwolla"],["Bill Pay","BillPay"],["Check"],["Cash"],["Other"]]
@payment_instructions = {nil => nil, @payment_instructions = {nil => nil,
:PayPal => "Set up a monthly recurring payment to hslfinances@gmail.com", :PayPal => "Set up a monthly recurring payment to hslfinances@gmail.com or via the button on the next page.",
:Dwolla => "Set up a monthly recurring payment to hslfinances@gmail.com", :Dwolla => "Set up a monthly recurring payment to hslfinances@gmail.com or via the button on the next page.",
:BillPay => "Have your bank send a monthly check to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201", :BillPay => "Have your bank send a monthly check to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201",
:Check => "Mail to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201 OR put in the drop safe at the Lab with a deposit slip firmly attached each month.", :Check => "Mail to HeatSync Labs Treasurer, 140 W Main St, Mesa AZ 85201 OR put in the drop safe at the Lab with a deposit slip firmly attached each month.",
:Cash => "Put in the drop safe at the Lab with a deposit slip firmly attached each month.", :Cash => "Put in the drop safe at the Lab with a deposit slip firmly attached each month.",
:Other => "Hmm... talk to a Treasurer!"} %> :Other => "Hmm... talk to a Treasurer!"} %>
<%= g.label :payment_method %> <i>(after changing this, please make sure you update your payment service, it's not automatic.)</i><br /> <%= g.label :payment_method %><% if params[:action] != 'new' %> <i>(after changing this, please make sure you update your payment service, it's not automatic.)</i><% end %><br />
<%= g.select :payment_method, @payment_methods %> <%= g.select :payment_method, @payment_methods %>
<% @payment_instructions.each_pair do |key, value| %> <% @payment_instructions.each_pair do |key, value| %>
<span class="payment_instructions" id="pmt_<%= key %>"><%= value %></span> <span class="payment_instructions" id="pmt_<%= key %>"><%= value %></span>

View File

@ -0,0 +1,7 @@
require 'test_helper'
class UserMailerTest < ActionMailer::TestCase
# test "the truth" do
# assert true
# end
end