summaryrefslogtreecommitdiffstats
path: root/app/controllers/timelog_controller.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-10-08 15:39:39 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-10-08 15:39:39 +0000
commit4acd990ee2950a575a35b32bdfd8a75f04e958b0 (patch)
tree2bf8be13397290bfae82a5e3ea7b8126b5615875 /app/controllers/timelog_controller.rb
parent84ebd786d6eb20693f8ba93a04be93e279be0289 (diff)
downloadredmine-4acd990ee2950a575a35b32bdfd8a75f04e958b0.tar.gz
redmine-4acd990ee2950a575a35b32bdfd8a75f04e958b0.zip
Refactor: extract TimelogController#create from TimelogController#edit
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4244 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/timelog_controller.rb')
-rw-r--r--app/controllers/timelog_controller.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb
index d15ea6a54..b9f8724a0 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, :edit, :destroy]
+ before_filter :find_project, :authorize, :only => [:new, :create, :edit, :destroy]
before_filter :find_optional_project, :only => [:index]
verify :method => :post, :only => :destroy, :redirect_to => { :action => :index }
@@ -93,6 +93,21 @@ class TimelogController < ApplicationController
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
render :action => 'edit'
end
+
+ verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
+ def create
+ @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 })
+
+ if @time_entry.save
+ flash[:notice] = l(:notice_successful_update)
+ redirect_back_or_default :action => 'index', :project_id => @time_entry.project
+ else
+ render :action => 'edit'
+ end
+ end
def edit
(render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)