Refactor: convert the Projects routes to resources.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4071 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
bf7476af5b
commit
8d52608dba
|
@ -35,7 +35,7 @@
|
|||
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %>
|
||||
<%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if !project.active? && (project.parent.nil? || project.parent.active?) %>
|
||||
<%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
|
||||
<%= link_to(l(:button_delete), { :controller => 'projects', :action => 'destroy', :id => project }, :class => 'icon icon-del') %>
|
||||
<%= link_to(l(:button_delete), project_destroy_confirm_path(project), :class => 'icon icon-del') %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% labelled_tabular_form_for :project, @project, :url => { :action => "update", :id => @project } do |f| %>
|
||||
<% labelled_tabular_form_for :project, @project, :url => project_path(@project), :html => {:method => (@project.new_record? ? :post : :put) } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<% end %>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<% end %>
|
||||
</p>
|
||||
<p>
|
||||
<% form_tag({:controller => 'projects', :action => 'destroy', :id => @project_to_destroy}) do %>
|
||||
<% form_tag(project_path(@project_to_destroy), :method => :delete) do %>
|
||||
<label><%= check_box_tag 'confirm', 1 %> <%= l(:general_text_Yes) %></label>
|
||||
<%= submit_tag l(:button_delete) %>
|
||||
<% end %>
|
||||
|
|
|
@ -172,48 +172,45 @@ ActionController::Routing::Routes.draw do |map|
|
|||
user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
|
||||
end
|
||||
end
|
||||
|
||||
map.with_options :controller => 'projects' do |projects|
|
||||
projects.with_options :conditions => {:method => :get} do |project_views|
|
||||
project_views.connect 'projects', :action => 'index'
|
||||
project_views.connect 'projects.:format', :action => 'index'
|
||||
project_views.connect 'projects/new', :action => 'new'
|
||||
project_views.connect 'projects/:id', :action => 'show'
|
||||
project_views.connect 'projects/:id.:format', :action => 'show'
|
||||
project_views.connect 'projects/:id/:action', :action => /destroy|settings/
|
||||
|
||||
map.resources :projects, :member => {
|
||||
:copy => [:get, :post],
|
||||
:settings => :get,
|
||||
:modules => :post,
|
||||
:archive => :post,
|
||||
:unarchive => :post
|
||||
}
|
||||
|
||||
# Destroy uses a get request to prompt the user before the actual DELETE request
|
||||
map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
|
||||
|
||||
# TODO: port to be part of the resources route(s)
|
||||
map.with_options :controller => 'projects' do |project_mapper|
|
||||
project_mapper.with_options :conditions => {:method => :get} do |project_views|
|
||||
project_views.connect 'projects/:id/files', :controller => 'files', :action => 'index'
|
||||
project_views.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
|
||||
project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
|
||||
project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
|
||||
project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
|
||||
end
|
||||
|
||||
projects.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
|
||||
activity.connect 'projects/:id/activity'
|
||||
activity.connect 'projects/:id/activity.:format'
|
||||
activity.connect 'activity', :id => nil
|
||||
activity.connect 'activity.:format', :id => nil
|
||||
end
|
||||
|
||||
projects.with_options :conditions => {:method => :post} do |project_actions|
|
||||
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/edit', :action => 'update'
|
||||
project_actions.connect 'projects/:id/:action', :action => /destroy|archive|unarchive/
|
||||
project_mapper.with_options :conditions => {:method => :post} do |project_actions|
|
||||
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 => 'update', :format => /xml/
|
||||
end
|
||||
|
||||
projects.with_options :conditions => {:method => :delete} do |project_actions|
|
||||
project_actions.conditions 'projects/:id.:format', :action => 'destroy', :format => /xml/
|
||||
project_mapper.with_options :conditions => {:method => :delete} do |project_actions|
|
||||
project_actions.conditions 'projects/:id/reset_activities', :controller => 'project_enumerations', :action => 'destroy'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
|
||||
activity.connect 'projects/:id/activity'
|
||||
activity.connect 'projects/:id/activity.:format'
|
||||
activity.connect 'activity', :id => nil
|
||||
activity.connect 'activity.:format', :id => nil
|
||||
end
|
||||
|
||||
map.with_options :controller => 'versions' do |versions|
|
||||
versions.connect 'projects/:project_id/versions/new', :action => 'new'
|
||||
versions.connect 'projects/:project_id/roadmap', :action => 'index'
|
||||
|
|
|
@ -171,24 +171,23 @@ class RoutingTest < ActionController::IntegrationTest
|
|||
should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
|
||||
should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
|
||||
should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
|
||||
should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567'
|
||||
should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :id => '33'
|
||||
should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
|
||||
should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
|
||||
should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
|
||||
should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
|
||||
|
||||
should_route :post, "/projects/new", :controller => 'projects', :action => 'create'
|
||||
should_route :post, "/projects", :controller => 'projects', :action => 'create'
|
||||
should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
|
||||
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/4223", :controller => 'projects', :action => 'update', :id => '4223'
|
||||
should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
|
||||
|
||||
should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
|
||||
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'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue