summaryrefslogtreecommitdiffstats
path: root/app/controllers/timelog_controller.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-10-11 15:31:42 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-10-11 15:31:42 +0000
commit435c90eb478e705dff9ea239fd280a958a4287e3 (patch)
tree531e116594529af7016f7360d78ae67e7e9cdacd /app/controllers/timelog_controller.rb
parent700c302fca1ef401eff2744ffc5d955406136b17 (diff)
downloadredmine-435c90eb478e705dff9ea239fd280a958a4287e3.tar.gz
redmine-435c90eb478e705dff9ea239fd280a958a4287e3.zip
Refactor: extract TimelogController#edit to #update
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4248 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/timelog_controller.rb')
-rw-r--r--app/controllers/timelog_controller.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb
index b9f8724a0..d533b10ef 100644
--- a/app/controllers/timelog_controller.rb
+++ b/app/controllers/timelog_controller.rb
@@ -17,7 +17,7 @@
class TimelogController < ApplicationController
menu_item :issues
- before_filter :find_project, :authorize, :only => [:new, :create, :edit, :destroy]
+ before_filter :find_project, :authorize, :only => [:new, :create, :edit, :update, :destroy]
before_filter :find_optional_project, :only => [:index]
verify :method => :post, :only => :destroy, :redirect_to => { :action => :index }
@@ -111,18 +111,26 @@ class TimelogController < ApplicationController
def edit
(render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
- @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
+ @time_entry.attributes = params[:time_entry]
+
+ call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
+ end
+
+ verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
+ def update
+ (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)
@time_entry.attributes = params[:time_entry]
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
- if request.post? and @time_entry.save
+ if @time_entry.save
flash[:notice] = l(:notice_successful_update)
redirect_back_or_default :action => 'index', :project_id => @time_entry.project
- return
+ else
+ render :action => 'edit'
end
end
-
+
def destroy
(render_404; return) unless @time_entry
(render_403; return) unless @time_entry.editable_by?(User.current)