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,14 +271,17 @@ private @issue = Issue.find(issue_id) @project ||= @issue.project end - if @project.nil? - render_404 - return false - 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 + end + end + def find_optional_project if !params[:issue_id].blank? @issue = Issue.find(params[:issue_id]) diff --git a/app/views/timelog/new.html.erb b/app/views/timelog/new.html.erb index 84bf7dae1..95253e82f 100644 --- a/app/views/timelog/new.html.erb +++ b/app/views/timelog/new.html.erb @@ -1,6 +1,7 @@