Skip to content

Commit

Permalink
Added welcome email that can be sent by admin
Browse files Browse the repository at this point in the history
  • Loading branch information
multiscan committed Aug 20, 2013
1 parent 76b92a8 commit 3e59e52
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/controllers/adm/admins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ def destroy
end
end

# GET /adm/admins/1/reset_password
def reset_password
@admin = Admin.find(params[:admin_id])
@admin.send_welcome_email
redirect_to [:adm, @admin], notice: "Reset password email was sent to #{@admin.name}"
end
private

def admin_params
Expand Down
7 changes: 7 additions & 0 deletions app/mailers/admin_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AdminMailer < ActionMailer::Base
default from: ENV['ADMIN_EMAIL']
def welcome_email(admin)
@admin=admin
mail(to: @admin.email, subject: "Wellcome to Thot")
end
end
4 changes: 4 additions & 0 deletions app/models/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ def locations
self.labs.map{|l| l.locations}.flatten!.uniq
end

def send_welcome_email
generate_reset_password_token!
AdminMailer.welcome_email(self).deliver
end
end
3 changes: 2 additions & 1 deletion app/views/adm/admins/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
=link_to "edit", edit_adm_admin_path(@admin)
|
=link_to "send an e-mail", "mailto:#{@admin.email}"

|
=link_to "send reset password e-mail", adm_admin_reset_password_path(@admin)
- if @admin.labs.count == 0
%p #{@admin.name} is managing no labs.
- else
Expand Down
16 changes: 16 additions & 0 deletions app/views/admin_mailer/welcome_email.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%p
Hello #{@admin.name}. Welcome to Thot.
%p
An operator account was created forr you on
=link_to "thot", root_url
Please click on the link below to set your account and set your password.
%p= link_to 'Click to initialize you account', edit_password_url(@admin, :reset_password_token => @admin.reset_password_token)

%p
For any question, please don't hesitate to contact
= link_to "me", "mailto:#{ENV['ADMIN_EMAIL']}"

%p
Best Regards,
%br
giovanni
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
# -------------------------------------------- for Operators and Administrator
devise_for :admins
namespace :adm do
resources :admins
resources :admins do
get :reset_password
end
resources :books do
get :autocomplete_publisher_name, :on => :collection
get :duplicate
Expand Down
28 changes: 28 additions & 0 deletions public/humans.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* the humans responsible & colophon */
/* humanstxt.org */

/* TEAM */
Developer: Giovanni Cangiani
Site: http://algo.epfl.ch/en/group/members/giovanni
Twitter: @multiscan
Location: Lausanne, Switzerland

Concept: Prof. Emre Telatar
Site: http://people.epfl.ch/131639

/* THANKS */
David Heinemeier Hansson (@dhh) and all the contributors of Ruby on Rails
Ryan Bates (@rbates) for his great railscasts tutorials
Steve Klabnik (@steveklabnik) for his work on improving Rails documentation
Thibaud Guillaume-Gentil (@thibaudgg) for great help on Ruby on Rails developments and for creating Guard
Zeno Crivelli (@zenoc) for introducing me to Ruby on Rails
Octave Zang (@octavez) for helpfull hints about css
Daniel Kehoe (@rails_apps) for the RailsApps project
Mike Bardet for kindly submittin many bugs and improvement suggestions


/* SITE */
Standards: HTML5, CSS3
Components: jQuery, Twitter Bootstrap
Software: Ruby on Rails, MySql, Linux

7 changes: 7 additions & 0 deletions test/mailers/admin_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class AdminMailerTest < ActionMailer::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit 3e59e52

Please sign in to comment.