summaryrefslogtreecommitdiffstats
path: root/app/controllers/timelog_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-05-29 18:54:26 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-05-29 18:54:26 +0000
commit4ee133e77eb7aea17f4674765d587708917da661 (patch)
tree04ca05f55edfedd8f3dfe915da05ec7756e4a22b /app/controllers/timelog_controller.rb
parent53a0cee57a0bbda3d47791eb189b5f4bd6511760 (diff)
downloadredmine-4ee133e77eb7aea17f4674765d587708917da661.tar.gz
redmine-4ee133e77eb7aea17f4674765d587708917da661.zip
Fixed that project, issue and activity should be preserved when logging time with "Create and continue" (#11038).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9741 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/timelog_controller.rb')
-rw-r--r--app/controllers/timelog_controller.rb24
1 files changed, 16 insertions, 8 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb
index 9cf8db500..dab2e0731 100644
--- a/app/controllers/timelog_controller.rb
+++ b/app/controllers/timelog_controller.rb
@@ -18,12 +18,13 @@
class TimelogController < ApplicationController
menu_item :issues
- before_filter :find_project, :only => [:create]
+ before_filter :find_project_for_new_time_entry, :only => [:create]
before_filter :find_time_entry, :only => [:show, :edit, :update]
before_filter :find_time_entries, :only => [:bulk_edit, :bulk_update, :destroy]
before_filter :authorize, :except => [:new, :index, :report]
- before_filter :find_optional_project, :only => [:new, :index, :report]
+ before_filter :find_optional_project, :only => [:index, :report]
+ before_filter :find_optional_project_for_new_time_entry, :only => [:new]
before_filter :authorize_global, :only => [:new, :index, :report]
accept_rss_auth :index
@@ -133,9 +134,13 @@ class TimelogController < ApplicationController
flash[:notice] = l(:notice_successful_create)
if params[:continue]
if params[:project_id]
- redirect_to :action => 'new', :project_id => @time_entry.project, :issue_id => @time_entry.issue, :back_url => params[:back_url]
+ redirect_to :action => 'new', :project_id => @time_entry.project, :issue_id => @time_entry.issue,
+ :time_entry => {:issue_id => @time_entry.issue_id, :activity_id => @time_entry.activity_id},
+ :back_url => params[:back_url]
else
- redirect_to :action => 'new', :back_url => params[:back_url]
+ redirect_to :action => 'new',
+ :time_entry => {:project_id => @time_entry.project_id, :issue_id => @time_entry.issue_id, :activity_id => @time_entry.activity_id},
+ :back_url => params[:back_url]
end
else
redirect_back_or_default :action => 'index', :project_id => @time_entry.project
@@ -258,7 +263,7 @@ private
end
end
- def find_project
+ def find_optional_project_for_new_time_entry
if (project_id = (params[:project_id] || params[:time_entry] && params[:time_entry][:project_id])).present?
@project = Project.find(project_id)
end
@@ -266,12 +271,15 @@ private
@issue = Issue.find(issue_id)
@project ||= @issue.project
end
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
+
+ def find_project_for_new_time_entry
+ find_optional_project_for_new_time_entry
if @project.nil?
render_404
- return false
end
- rescue ActiveRecord::RecordNotFound
- render_404
end
def find_optional_project