Commit 7448339ab0e3954be1471d247b451200e06a8ba7

Authored by AntonioTerceiro
1 parent 80f4ac9c

ActionItem78: checkpoint



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@633 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/change_password.rb
... ... @@ -49,4 +49,27 @@ class ChangePassword < Task
49 49 user.force_change_password!(self.password, self.password_confirmation)
50 50 end
51 51  
  52 + # overriding messages
  53 +
  54 + def cancel_message
  55 + _('Your password change request was cancelled at %s.') % Time.now.to_s
  56 + end
  57 +
  58 + def finish_message
  59 + _('Your password was changed successfully.')
  60 + end
  61 +
  62 + def create_message
  63 + hostname = self.requestor.environment.default_hostname
  64 + hash = self.id
  65 +
  66 + lambda do
  67 + _("In order to change your password, please visit the following address:\n\n%s") % url_for(:host => hostname, :controller => 'account', :action => 'change_password', :hash => hash)
  68 + end
  69 + end
  70 +
  71 + def description
  72 + _('Password change request')
  73 + end
  74 +
52 75 end
... ...
app/models/task_mailer.rb
... ... @@ -15,11 +15,19 @@ class TaskMailer < ActionMailer::Base
15 15 protected
16 16  
17 17 def send_message(task, message)
  18 +
  19 + text =
  20 + if message.kind_of?(Proc)
  21 + self.instance_eval(&message)
  22 + else
  23 + message
  24 + end
  25 +
18 26 recipients task.requestor.email
19 27 from task.requestor.environment.contact_email
20 28 subject task.description
21 29 body :requestor => task.requestor.name,
22   - :message => message,
  30 + :message => text,
23 31 :environment => task.requestor.environment.name,
24 32 :url => url_for(:host => task.requestor.environment.default_hostname, :controller => 'home')
25 33 end
... ...
config/routes.rb
... ... @@ -19,7 +19,10 @@ ActionController::Routing::Routes.draw do |map|
19 19 map.connect 'doc', :controller => 'doc'
20 20  
21 21 # user account controller
  22 + map.connect 'account/change_password/:hash', :controller => 'account', :action => 'change_password'
  23 +
22 24 map.connect 'account/:action', :controller => 'account'
  25 +
23 26  
24 27 ######################################################
25 28 ## Controllers that are profile-specific (for profile admins )
... ...
db/migrate/017_create_tasks.rb
... ... @@ -7,6 +7,8 @@ class CreateTasks < ActiveRecord::Migration
7 7  
8 8 t.column :requestor_id, :integer
9 9 t.column :target_id, :integer
  10 +
  11 + t.column :hash, :string
10 12 end
11 13 end
12 14  
... ...
test/unit/task_test.rb
... ... @@ -88,5 +88,9 @@ class TaskTest < Test::Unit::TestCase
88 88 task.save!
89 89 end
90 90  
  91 + should 'generate a random hash when creating' do
  92 + flunk 'not implemented yet'
  93 + end
  94 +
91 95  
92 96 end
... ...