git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4070 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/1.1.0
@@ -25,13 +25,16 @@ class ProjectsController < ApplicationController | |||
before_filter :authorize_global, :only => [:new, :create] | |||
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] | |||
accept_key_auth :index | |||
after_filter :only => [:create, :edit, :archive, :unarchive, :destroy] do |controller| | |||
after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller| | |||
if controller.request.post? | |||
controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt' | |||
end | |||
end | |||
# TODO: convert to PUT only | |||
verify :method => [:post, :put], :only => :update, :render => {:nothing => true, :status => :method_not_allowed } | |||
helper :sort | |||
include SortHelper | |||
helper :custom_fields | |||
@@ -179,28 +182,27 @@ class ProjectsController < ApplicationController | |||
@wiki ||= @project.wiki | |||
end | |||
# Edit @project | |||
def edit | |||
if request.get? | |||
end | |||
def update | |||
@project.attributes = params[:project] | |||
if validate_parent_id && @project.save | |||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') | |||
respond_to do |format| | |||
format.html { | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_to :action => 'settings', :id => @project | |||
} | |||
format.xml { head :ok } | |||
end | |||
else | |||
@project.attributes = params[:project] | |||
if validate_parent_id && @project.save | |||
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') | |||
respond_to do |format| | |||
format.html { | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_to :action => 'settings', :id => @project | |||
} | |||
format.xml { head :ok } | |||
end | |||
else | |||
respond_to do |format| | |||
format.html { | |||
settings | |||
render :action => 'settings' | |||
} | |||
format.xml { render :xml => @project.errors, :status => :unprocessable_entity } | |||
end | |||
respond_to do |format| | |||
format.html { | |||
settings | |||
render :action => 'settings' | |||
} | |||
format.xml { render :xml => @project.errors, :status => :unprocessable_entity } | |||
end | |||
end | |||
end |
@@ -1,4 +1,4 @@ | |||
<% labelled_tabular_form_for :project, @project, :url => { :action => "edit", :id => @project } do |f| %> | |||
<% labelled_tabular_form_for :project, @project, :url => { :action => "update", :id => @project } do |f| %> | |||
<%= render :partial => 'form', :locals => { :f => f } %> | |||
<%= submit_tag l(:button_save) %> | |||
<% end %> |
@@ -198,13 +198,14 @@ ActionController::Routing::Routes.draw do |map| | |||
project_actions.connect 'projects/new', :action => 'create' | |||
project_actions.connect 'projects', :action => 'create' | |||
project_actions.connect 'projects.:format', :action => 'create', :format => /xml/ | |||
project_actions.connect 'projects/:id/:action', :action => /edit|destroy|archive|unarchive/ | |||
project_actions.connect 'projects/:id/edit', :action => 'update' | |||
project_actions.connect 'projects/:id/:action', :action => /destroy|archive|unarchive/ | |||
project_actions.connect 'projects/:id/files/new', :controller => 'files', :action => 'new' | |||
project_actions.connect 'projects/:id/activities/save', :controller => 'project_enumerations', :action => 'save' | |||
end | |||
projects.with_options :conditions => {:method => :put} do |project_actions| | |||
project_actions.conditions 'projects/:id.:format', :action => 'edit', :format => /xml/ | |||
project_actions.conditions 'projects/:id.:format', :action => 'update', :format => /xml/ | |||
end | |||
projects.with_options :conditions => {:method => :delete} do |project_actions| |
@@ -47,7 +47,7 @@ Redmine::AccessControl.map do |map| | |||
map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true | |||
map.permission :search_project, {:search => :index}, :public => true | |||
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin | |||
map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member | |||
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member | |||
map.permission :select_project_modules, {:projects => :modules}, :require => :member | |||
map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member | |||
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member |
@@ -318,9 +318,9 @@ class ProjectsControllerTest < ActionController::TestCase | |||
assert_template 'settings' | |||
end | |||
def test_edit | |||
def test_update | |||
@request.session[:user_id] = 2 # manager | |||
post :edit, :id => 1, :project => {:name => 'Test changed name', | |||
post :update, :id => 1, :project => {:name => 'Test changed name', | |||
:issue_custom_field_ids => ['']} | |||
assert_redirected_to 'projects/ecookbook/settings' | |||
project = Project.find(1) |
@@ -180,14 +180,14 @@ class RoutingTest < ActionController::IntegrationTest | |||
should_route :post, "/projects/new", :controller => 'projects', :action => 'create' | |||
should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml' | |||
should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'edit', :id => '4223' | |||
should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'update', :id => '4223' | |||
should_route :post, "/projects/64/destroy", :controller => 'projects', :action => 'destroy', :id => '64' | |||
should_route :post, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33' | |||
should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64' | |||
should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64' | |||
should_route :post, "/projects/64/activities/save", :controller => 'project_enumerations', :action => 'save', :id => '64' | |||
should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'edit', :id => '1', :format => 'xml' | |||
should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml' | |||
should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml' | |||
should_route :delete, "/projects/64/reset_activities", :controller => 'project_enumerations', :action => 'destroy', :id => '64' |