##// END OF EJS Templates
Refactor: convert the Projects routes to resources....
Eric Davis -
r3957:8d52608dbad6
parent child
Show More
@@ -35,7 +35,7
35 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 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 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 39 </td>
40 40 </tr>
41 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 2 <%= render :partial => 'form', :locals => { :f => f } %>
3 3 <%= submit_tag l(:button_save) %>
4 4 <% end %>
@@ -8,7 +8,7
8 8 <% end %>
9 9 </p>
10 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 12 <label><%= check_box_tag 'confirm', 1 %> <%= l(:general_text_Yes) %></label>
13 13 <%= submit_tag l(:button_delete) %>
14 14 <% end %>
@@ -173,45 +173,42 ActionController::Routing::Routes.draw do |map|
173 173 end
174 174 end
175 175
176 map.with_options :controller => 'projects' do |projects|
177 projects.with_options :conditions => {:method => :get} do |project_views|
178 project_views.connect 'projects', :action => 'index'
179 project_views.connect 'projects.:format', :action => 'index'
180 project_views.connect 'projects/new', :action => 'new'
181 project_views.connect 'projects/:id', :action => 'show'
182 project_views.connect 'projects/:id.:format', :action => 'show'
183 project_views.connect 'projects/:id/:action', :action => /destroy|settings/
176 map.resources :projects, :member => {
177 :copy => [:get, :post],
178 :settings => :get,
179 :modules => :post,
180 :archive => :post,
181 :unarchive => :post
182 }
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 190 project_views.connect 'projects/:id/files', :controller => 'files', :action => 'index'
185 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 193 project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
188 194 end
189 195
190 projects.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity|
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/
196 project_mapper.with_options :conditions => {:method => :post} do |project_actions|
203 197 project_actions.connect 'projects/:id/files/new', :controller => 'files', :action => 'new'
204 198 project_actions.connect 'projects/:id/activities/save', :controller => 'project_enumerations', :action => 'save'
205 199 end
206 200
207 projects.with_options :conditions => {:method => :put} do |project_actions|
208 project_actions.conditions 'projects/:id.:format', :action => 'update', :format => /xml/
201 project_mapper.with_options :conditions => {:method => :delete} do |project_actions|
202 project_actions.conditions 'projects/:id/reset_activities', :controller => 'project_enumerations', :action => 'destroy'
209 203 end
210 204
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'
214 205 end
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
215 212 end
216 213
217 214 map.with_options :controller => 'versions' do |versions|
@@ -171,24 +171,23 class RoutingTest < ActionController::IntegrationTest
171 171 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
172 172 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
173 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 174 should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :id => '33'
176 175 should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
177 176 should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33'
178 177 should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33'
179 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 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 182 should_route :post, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33'
186 183 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
187 184 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
188 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 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 191 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
193 192 should_route :delete, "/projects/64/reset_activities", :controller => 'project_enumerations', :action => 'destroy', :id => '64'
194 193 end
General Comments 0
You need to be logged in to leave comments. Login now