diff options
Diffstat (limited to 'app/controllers/timelog_controller.rb')
-rw-r--r-- | app/controllers/timelog_controller.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 4ae4aa277..e0b3826e8 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 |