Refactor: extract TimelogController#new from #edit

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4239 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2010-10-07 15:51:09 +00:00
parent e59156b446
commit 068771ea07
7 changed files with 31 additions and 22 deletions
+9 -1
View File
@@ -17,7 +17,7 @@
class TimelogController < ApplicationController
menu_item :issues
before_filter :find_project, :authorize, :only => [:edit, :destroy]
before_filter :find_project, :authorize, :only => [:new, :edit, :destroy]
before_filter :find_optional_project, :only => [:index]
verify :method => :post, :only => :destroy, :redirect_to => { :action => :index }
@@ -85,6 +85,14 @@ class TimelogController < ApplicationController
end
end
end
def new
@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 })
render :action => 'edit'
end
def edit
(render_403; return) if @time_entry && !@time_entry.editable_by?(User.current)