Commit 7448339ab0e3954be1471d247b451200e06a8ba7
1 parent
80f4ac9c
Exists in
master
and in
22 other branches
ActionItem78: checkpoint
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@633 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
41 additions
and
1 deletions
Show diff stats
app/models/change_password.rb
| @@ -49,4 +49,27 @@ class ChangePassword < Task | @@ -49,4 +49,27 @@ class ChangePassword < Task | ||
| 49 | user.force_change_password!(self.password, self.password_confirmation) | 49 | user.force_change_password!(self.password, self.password_confirmation) |
| 50 | end | 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 | end | 75 | end |
app/models/task_mailer.rb
| @@ -15,11 +15,19 @@ class TaskMailer < ActionMailer::Base | @@ -15,11 +15,19 @@ class TaskMailer < ActionMailer::Base | ||
| 15 | protected | 15 | protected |
| 16 | 16 | ||
| 17 | def send_message(task, message) | 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 | recipients task.requestor.email | 26 | recipients task.requestor.email |
| 19 | from task.requestor.environment.contact_email | 27 | from task.requestor.environment.contact_email |
| 20 | subject task.description | 28 | subject task.description |
| 21 | body :requestor => task.requestor.name, | 29 | body :requestor => task.requestor.name, |
| 22 | - :message => message, | 30 | + :message => text, |
| 23 | :environment => task.requestor.environment.name, | 31 | :environment => task.requestor.environment.name, |
| 24 | :url => url_for(:host => task.requestor.environment.default_hostname, :controller => 'home') | 32 | :url => url_for(:host => task.requestor.environment.default_hostname, :controller => 'home') |
| 25 | end | 33 | end |
config/routes.rb
| @@ -19,7 +19,10 @@ ActionController::Routing::Routes.draw do |map| | @@ -19,7 +19,10 @@ ActionController::Routing::Routes.draw do |map| | ||
| 19 | map.connect 'doc', :controller => 'doc' | 19 | map.connect 'doc', :controller => 'doc' |
| 20 | 20 | ||
| 21 | # user account controller | 21 | # user account controller |
| 22 | + map.connect 'account/change_password/:hash', :controller => 'account', :action => 'change_password' | ||
| 23 | + | ||
| 22 | map.connect 'account/:action', :controller => 'account' | 24 | map.connect 'account/:action', :controller => 'account' |
| 25 | + | ||
| 23 | 26 | ||
| 24 | ###################################################### | 27 | ###################################################### |
| 25 | ## Controllers that are profile-specific (for profile admins ) | 28 | ## Controllers that are profile-specific (for profile admins ) |
db/migrate/017_create_tasks.rb
| @@ -7,6 +7,8 @@ class CreateTasks < ActiveRecord::Migration | @@ -7,6 +7,8 @@ class CreateTasks < ActiveRecord::Migration | ||
| 7 | 7 | ||
| 8 | t.column :requestor_id, :integer | 8 | t.column :requestor_id, :integer |
| 9 | t.column :target_id, :integer | 9 | t.column :target_id, :integer |
| 10 | + | ||
| 11 | + t.column :hash, :string | ||
| 10 | end | 12 | end |
| 11 | end | 13 | end |
| 12 | 14 |
test/unit/task_test.rb