@@ -25,13 +25,16 class ProjectsController < ApplicationController | |||
|
25 | 25 | before_filter :authorize_global, :only => [:new, :create] |
|
26 | 26 | before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] |
|
27 | 27 | accept_key_auth :index |
|
28 | ||
|
29 | after_filter :only => [:create, :edit, :archive, :unarchive, :destroy] do |controller| | |
|
28 | ||
|
29 | after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller| | |
|
30 | 30 | if controller.request.post? |
|
31 | 31 | controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt' |
|
32 | 32 | end |
|
33 | 33 | end |
|
34 | ||
|
34 | ||
|
35 | # TODO: convert to PUT only | |
|
36 | verify :method => [:post, :put], :only => :update, :render => {:nothing => true, :status => :method_not_allowed } | |
|
37 | ||
|
35 | 38 | helper :sort |
|
36 | 39 | include SortHelper |
|
37 | 40 | helper :custom_fields |
@@ -179,28 +182,27 class ProjectsController < ApplicationController | |||
|
179 | 182 | @wiki ||= @project.wiki |
|
180 | 183 | end |
|
181 | 184 | |
|
182 | # Edit @project | |
|
183 | 185 | def edit |
|
184 | if request.get? | |
|
186 | end | |
|
187 | ||
|
188 | def update | |
|
189 | @project.attributes = params[:project] | |
|
190 | if validate_parent_id && @project.save | |
|
191 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') | |
|
192 | respond_to do |format| | |
|
193 | format.html { | |
|
194 | flash[:notice] = l(:notice_successful_update) | |
|
195 | redirect_to :action => 'settings', :id => @project | |
|
196 | } | |
|
197 | format.xml { head :ok } | |
|
198 | end | |
|
185 | 199 | else |
|
186 | @project.attributes = params[:project] | |
|
187 | if validate_parent_id && @project.save | |
|
188 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') | |
|
189 | respond_to do |format| | |
|
190 | format.html { | |
|
191 | flash[:notice] = l(:notice_successful_update) | |
|
192 | redirect_to :action => 'settings', :id => @project | |
|
193 | } | |
|
194 | format.xml { head :ok } | |
|
195 | end | |
|
196 | else | |
|
197 | respond_to do |format| | |
|
198 | format.html { | |
|
199 | settings | |
|
200 | render :action => 'settings' | |
|
201 | } | |
|
202 | format.xml { render :xml => @project.errors, :status => :unprocessable_entity } | |
|
203 | end | |
|
200 | respond_to do |format| | |
|
201 | format.html { | |
|
202 | settings | |
|
203 | render :action => 'settings' | |
|
204 | } | |
|
205 | format.xml { render :xml => @project.errors, :status => :unprocessable_entity } | |
|
204 | 206 | end |
|
205 | 207 | end |
|
206 | 208 | end |
@@ -1,4 +1,4 | |||
|
1 |
<% labelled_tabular_form_for :project, @project, :url => { :action => " |
|
|
1 | <% labelled_tabular_form_for :project, @project, :url => { :action => "update", :id => @project } do |f| %> | |
|
2 | 2 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
3 | 3 | <%= submit_tag l(:button_save) %> |
|
4 | 4 | <% end %> |
@@ -216,13 +216,14 ActionController::Routing::Routes.draw do |map| | |||
|
216 | 216 | project_actions.connect 'projects/new', :action => 'create' |
|
217 | 217 | project_actions.connect 'projects', :action => 'create' |
|
218 | 218 | project_actions.connect 'projects.:format', :action => 'create', :format => /xml/ |
|
219 |
project_actions.connect 'projects/:id/ |
|
|
219 | project_actions.connect 'projects/:id/edit', :action => 'update' | |
|
220 | project_actions.connect 'projects/:id/:action', :action => /destroy|archive|unarchive/ | |
|
220 | 221 | project_actions.connect 'projects/:id/files/new', :controller => 'files', :action => 'new' |
|
221 | 222 | project_actions.connect 'projects/:id/activities/save', :controller => 'project_enumerations', :action => 'save' |
|
222 | 223 | end |
|
223 | 224 | |
|
224 | 225 | projects.with_options :conditions => {:method => :put} do |project_actions| |
|
225 |
project_actions.conditions 'projects/:id.:format', :action => ' |
|
|
226 | project_actions.conditions 'projects/:id.:format', :action => 'update', :format => /xml/ | |
|
226 | 227 | end |
|
227 | 228 | |
|
228 | 229 | projects.with_options :conditions => {:method => :delete} do |project_actions| |
@@ -47,7 +47,7 Redmine::AccessControl.map do |map| | |||
|
47 | 47 | map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true |
|
48 | 48 | map.permission :search_project, {:search => :index}, :public => true |
|
49 | 49 | map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin |
|
50 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member | |
|
50 | map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member | |
|
51 | 51 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
52 | 52 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member |
|
53 | 53 | map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member |
@@ -318,9 +318,9 class ProjectsControllerTest < ActionController::TestCase | |||
|
318 | 318 | assert_template 'settings' |
|
319 | 319 | end |
|
320 | 320 | |
|
321 |
def test_ |
|
|
321 | def test_update | |
|
322 | 322 | @request.session[:user_id] = 2 # manager |
|
323 |
post : |
|
|
323 | post :update, :id => 1, :project => {:name => 'Test changed name', | |
|
324 | 324 | :issue_custom_field_ids => ['']} |
|
325 | 325 | assert_redirected_to 'projects/ecookbook/settings' |
|
326 | 326 | project = Project.find(1) |
@@ -180,14 +180,14 class RoutingTest < ActionController::IntegrationTest | |||
|
180 | 180 | |
|
181 | 181 | should_route :post, "/projects/new", :controller => 'projects', :action => 'create' |
|
182 | 182 | should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml' |
|
183 |
should_route :post, "/projects/4223/edit", :controller => 'projects', :action => ' |
|
|
183 | should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'update', :id => '4223' | |
|
184 | 184 | should_route :post, "/projects/64/destroy", :controller => 'projects', :action => 'destroy', :id => '64' |
|
185 | 185 | should_route :post, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33' |
|
186 | 186 | should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64' |
|
187 | 187 | should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64' |
|
188 | 188 | should_route :post, "/projects/64/activities/save", :controller => 'project_enumerations', :action => 'save', :id => '64' |
|
189 | 189 | |
|
190 |
should_route :put, "/projects/1.xml", :controller => 'projects', :action => ' |
|
|
190 | should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml' | |
|
191 | 191 | |
|
192 | 192 | should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml' |
|
193 | 193 | should_route :delete, "/projects/64/reset_activities", :controller => 'project_enumerations', :action => 'destroy', :id => '64' |
General Comments 0
You need to be logged in to leave comments.
Login now