##// END OF EJS Templates
Refactor: convert the Projects routes to resources....
Eric Davis -
r3957:8d52608dbad6
parent child
Show More
@@ -35,7 +35,7
35 <%= 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? %>
35 <%= 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? %>
36 <%= 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?) %>
36 <%= 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?) %>
37 <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
37 <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %>
38 <%= link_to(l(:button_delete), { :controller => 'projects', :action => 'destroy', :id => project }, :class => 'icon icon-del') %>
38 <%= link_to(l(:button_delete), project_destroy_confirm_path(project), :class => 'icon icon-del') %>
39 </td>
39 </td>
40 </tr>
40 </tr>
41 <% end %>
41 <% end %>
@@ -1,4 +1,4
1 <% labelled_tabular_form_for :project, @project, :url => { :action => "update", :id => @project } do |f| %>
1 <% labelled_tabular_form_for :project, @project, :url => project_path(@project), :html => {:method => (@project.new_record? ? :post : :put) } 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 %>
@@ -8,7 +8,7
8 <% end %>
8 <% end %>
9 </p>
9 </p>
10 <p>
10 <p>
11 <% form_tag({:controller => 'projects', :action => 'destroy', :id => @project_to_destroy}) do %>
11 <% form_tag(project_path(@project_to_destroy), :method => :delete) do %>
12 <label><%= check_box_tag 'confirm', 1 %> <%= l(:general_text_Yes) %></label>
12 <label><%= check_box_tag 'confirm', 1 %> <%= l(:general_text_Yes) %></label>
13 <%= submit_tag l(:button_delete) %>
13 <%= submit_tag l(:button_delete) %>
14 <% end %>
14 <% end %>
@@ -172,48 +172,45 ActionController::Routing::Routes.draw do |map|
172 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
172 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
173 end
173 end
174 end
174 end
175
175
176 map.with_options :controller => 'projects' do |projects|
176 map.resources :projects, :member => {
177 projects.with_options :conditions => {:method => :get} do |project_views|
177 :copy => [:get, :post],
178 project_views.connect 'projects', :action => 'index'
178 :settings => :get,
179 project_views.connect 'projects.:format', :action => 'index'
179 :modules => :post,
180 project_views.connect 'projects/new', :action => 'new'
180 :archive => :post,
181 project_views.connect 'projects/:id', :action => 'show'
181 :unarchive => :post
182 project_views.connect 'projects/:id.:format', :action => 'show'
182 }
183 project_views.connect 'projects/:id/:action', :action => /destroy|settings/
183
184 # Destroy uses a get request to prompt the user before the actual DELETE request
185 map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get}
186
187 # TODO: port to be part of the resources route(s)
188 map.with_options :controller => 'projects' do |project_mapper|
189 project_mapper.with_options :conditions => {:method => :get} do |project_views|
184 project_views.connect 'projects/:id/files', :controller => 'files', :action => 'index'
190 project_views.connect 'projects/:id/files', :controller => 'files', :action => 'index'
185 project_views.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
191 project_views.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
186 project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
192 project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings'
187 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
193 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
188 end
194 end
189
195
190 projects.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
196 project_mapper.with_options :conditions => {:method => :post} do |project_actions|
191 activity.connect 'projects/:id/activity'
192 activity.connect 'projects/:id/activity.:format'
193 activity.connect 'activity', :id => nil
194 activity.connect 'activity.:format', :id => nil
195 end
196
197 projects.with_options :conditions => {:method => :post} do |project_actions|
198 project_actions.connect 'projects/new', :action => 'create'
199 project_actions.connect 'projects', :action => 'create'
200 project_actions.connect 'projects.:format', :action => 'create', :format => /xml/
201 project_actions.connect 'projects/:id/edit', :action => 'update'
202 project_actions.connect 'projects/:id/:action', :action => /destroy|archive|unarchive/
203 project_actions.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
197 project_actions.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
204 project_actions.connect 'projects/:id/activities/save', :controller => 'project_enumerations', :action => 'save'
198 project_actions.connect 'projects/:id/activities/save', :controller => 'project_enumerations', :action => 'save'
205 end
199 end
206
200
207 projects.with_options :conditions => {:method => :put} do |project_actions|
201 project_mapper.with_options :conditions => {:method => :delete} do |project_actions|
208 project_actions.conditions 'projects/:id.:format', :action => 'update', :format => /xml/
209 end
210
211 projects.with_options :conditions => {:method => :delete} do |project_actions|
212 project_actions.conditions 'projects/:id.:format', :action => 'destroy', :format => /xml/
213 project_actions.conditions 'projects/:id/reset_activities', :controller => 'project_enumerations', :action => 'destroy'
202 project_actions.conditions 'projects/:id/reset_activities', :controller => 'project_enumerations', :action => 'destroy'
214 end
203 end
204
215 end
205 end
216
206
207 map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
208 activity.connect 'projects/:id/activity'
209 activity.connect 'projects/:id/activity.:format'
210 activity.connect 'activity', :id => nil
211 activity.connect 'activity.:format', :id => nil
212 end
213
217 map.with_options :controller => 'versions' do |versions|
214 map.with_options :controller => 'versions' do |versions|
218 versions.connect 'projects/:project_id/versions/new', :action => 'new'
215 versions.connect 'projects/:project_id/versions/new', :action => 'new'
219 versions.connect 'projects/:project_id/roadmap', :action => 'index'
216 versions.connect 'projects/:project_id/roadmap', :action => 'index'
@@ -171,24 +171,23 class RoutingTest < ActionController::IntegrationTest
171 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
171 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
172 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
172 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
173 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
173 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
174 should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567'
175 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :id => '33'
174 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :id => '33'
176 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
175 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
177 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
176 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
178 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
177 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
179 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
178 should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom'
180
179
181 should_route :post, "/projects/new", :controller => 'projects', :action => 'create'
180 should_route :post, "/projects", :controller => 'projects', :action => 'create'
182 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
181 should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml'
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'
185 should_route :post, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
182 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'
183 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'
184 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'
185 should_route :post, "/projects/64/activities/save", :controller => 'project_enumerations', :action => 'save', :id => '64'
189
186
187 should_route :put, "/projects/4223", :controller => 'projects', :action => 'update', :id => '4223'
190 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
188 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'update', :id => '1', :format => 'xml'
191
189
190 should_route :delete, "/projects/64", :controller => 'projects', :action => 'destroy', :id => '64'
192 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
191 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'
192 should_route :delete, "/projects/64/reset_activities", :controller => 'project_enumerations', :action => 'destroy', :id => '64'
194 end
193 end
General Comments 0
You need to be logged in to leave comments. Login now