@@ -17,7 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class TimelogController < ApplicationController |
|
19 | 19 | menu_item :issues |
|
20 | before_filter :find_project, :authorize, :only => [:new, :create, :edit, :destroy] | |
|
20 | before_filter :find_project, :authorize, :only => [:new, :create, :edit, :update, :destroy] | |
|
21 | 21 | before_filter :find_optional_project, :only => [:index] |
|
22 | 22 | |
|
23 | 23 | verify :method => :post, :only => :destroy, :redirect_to => { :action => :index } |
@@ -111,15 +111,23 class TimelogController < ApplicationController | |||
|
111 | 111 | |
|
112 | 112 | def edit |
|
113 | 113 | (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current) |
|
114 | @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today) | |
|
114 | @time_entry.attributes = params[:time_entry] | |
|
115 | ||
|
116 | call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) | |
|
117 | end | |
|
118 | ||
|
119 | verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } | |
|
120 | def update | |
|
121 | (render_403; return) if @time_entry && !@time_entry.editable_by?(User.current) | |
|
115 | 122 | @time_entry.attributes = params[:time_entry] |
|
116 | 123 | |
|
117 | 124 | call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry }) |
|
118 | 125 | |
|
119 |
if |
|
|
126 | if @time_entry.save | |
|
120 | 127 | flash[:notice] = l(:notice_successful_update) |
|
121 | 128 | redirect_back_or_default :action => 'index', :project_id => @time_entry.project |
|
122 | return | |
|
129 | else | |
|
130 | render :action => 'edit' | |
|
123 | 131 | end |
|
124 | 132 | end |
|
125 | 133 |
@@ -1,6 +1,11 | |||
|
1 | 1 | <h2><%= l(:label_spent_time) %></h2> |
|
2 | 2 | |
|
3 | <% labelled_tabular_form_for :time_entry, @time_entry, :url => {:action => (@time_entry.new_record? ? 'create' : 'edit'), :id => @time_entry, :project_id => @time_entry.project} do |f| %> | |
|
3 | <% labelled_tabular_form_for(:time_entry, @time_entry, :url => { | |
|
4 | :action => (@time_entry.new_record? ? 'create' : 'update'), | |
|
5 | :id => @time_entry, | |
|
6 | :project_id => @time_entry.project | |
|
7 | }, | |
|
8 | :html => {:method => @time_entry.new_record? ? :post : :put}) do |f| %> | |
|
4 | 9 | <%= error_messages_for 'time_entry' %> |
|
5 | 10 | <%= back_url_hidden_field_tag %> |
|
6 | 11 |
@@ -15,6 +15,7 ActionController::Routing::Routes.draw do |map| | |||
|
15 | 15 | map.connect 'help/:ctrl/:page', :controller => 'help' |
|
16 | 16 | |
|
17 | 17 | map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog' |
|
18 | map.connect 'time_entries/:id', :action => 'update', :controller => 'timelog', :conditions => {:method => :put} | |
|
18 | 19 | map.connect 'projects/:project_id/time_entries/new', :action => 'new', :controller => 'timelog' |
|
19 | 20 | map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'new', :controller => 'timelog' |
|
20 | 21 |
@@ -84,10 +84,10 Redmine::AccessControl.map do |map| | |||
|
84 | 84 | end |
|
85 | 85 | |
|
86 | 86 | map.project_module :time_tracking do |map| |
|
87 | map.permission :log_time, {:timelog => [:new, :create, :edit]}, :require => :loggedin | |
|
87 | map.permission :log_time, {:timelog => [:new, :create, :edit, :update]}, :require => :loggedin | |
|
88 | 88 | map.permission :view_time_entries, :timelog => [:index], :time_entry_reports => [:report] |
|
89 | map.permission :edit_time_entries, {:timelog => [:new, :create, :edit, :destroy]}, :require => :member | |
|
90 | map.permission :edit_own_time_entries, {:timelog => [:new, :create, :edit, :destroy]}, :require => :loggedin | |
|
89 | map.permission :edit_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy]}, :require => :member | |
|
90 | map.permission :edit_own_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin | |
|
91 | 91 | map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member |
|
92 | 92 | end |
|
93 | 93 |
@@ -56,7 +56,7 class TimelogControllerTest < ActionController::TestCase | |||
|
56 | 56 | assert_response :success |
|
57 | 57 | assert_template 'edit' |
|
58 | 58 | # Default activity selected |
|
59 |
assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/timelog/ |
|
|
59 | assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/timelog/update/2' } | |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | def test_get_edit_with_an_existing_time_entry_with_inactive_activity |
@@ -101,7 +101,7 class TimelogControllerTest < ActionController::TestCase | |||
|
101 | 101 | assert_equal 2, entry.user_id |
|
102 | 102 | |
|
103 | 103 | @request.session[:user_id] = 1 |
|
104 |
p |
|
|
104 | put :update, :id => 1, | |
|
105 | 105 | :time_entry => {:issue_id => '2', |
|
106 | 106 | :hours => '8'} |
|
107 | 107 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
@@ -239,8 +239,9 class RoutingTest < ActionController::IntegrationTest | |||
|
239 | 239 | should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' |
|
240 | 240 | |
|
241 | 241 | should_route :post, "/projects/ecookbook/timelog/edit", :controller => 'timelog', :action => 'create', :project_id => 'ecookbook' |
|
242 | should_route :post, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22' | |
|
243 | 242 | should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55' |
|
243 | ||
|
244 | should_route :put, "/time_entries/22", :controller => 'timelog', :action => 'update', :id => '22' | |
|
244 | 245 | end |
|
245 | 246 | |
|
246 | 247 | context "time_entry_reports" do |
General Comments 0
You need to be logged in to leave comments.
Login now