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