Refactor: convert many of the custom Issue routes to REST resources.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4041 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
daa4272c0e
commit
56e984b5e7
|
@ -32,8 +32,11 @@ class CalendarsController < ApplicationController
|
|||
@calendar.events = events
|
||||
end
|
||||
|
||||
render :layout => false if request.xhr?
|
||||
render :action => 'show', :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def update
|
||||
show
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -43,4 +43,8 @@ class GanttsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def update
|
||||
show
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<h2><%= l(:label_calendar) %></h2>
|
||||
|
||||
<% form_tag({}, :id => 'query_form') do %>
|
||||
<% form_tag(calendar_path, :method => :put, :id => 'query_form') do %>
|
||||
<%= hidden_field_tag('project_id', @project.to_param) if @project%>
|
||||
<fieldset id="filters" class="collapsible">
|
||||
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
|
||||
<div>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<h2><%= l(:label_gantt) %></h2>
|
||||
|
||||
<% form_tag(params.merge(:month => nil, :year => nil, :months => nil), :id => 'query_form') do %>
|
||||
<% form_tag(gantt_path(:month => params[:month], :year => params[:year], :months => params[:months]), :method => :put, :id => 'query_form') do %>
|
||||
<%= hidden_field_tag('project_id', @project.to_param) if @project%>
|
||||
<fieldset id="filters" class="collapsible">
|
||||
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
|
||||
<div>
|
||||
|
|
|
@ -104,58 +104,39 @@ ActionController::Routing::Routes.draw do |map|
|
|||
end
|
||||
|
||||
map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move'
|
||||
|
||||
# Misc issue routes. TODO: move into resources
|
||||
map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues'
|
||||
# TODO: would look nicer as /issues/:id/preview
|
||||
map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue'
|
||||
map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview
|
||||
map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
|
||||
map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
|
||||
map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get }
|
||||
map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post }
|
||||
map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
|
||||
map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
|
||||
|
||||
map.with_options :controller => 'issues' do |issues_routes|
|
||||
issues_routes.with_options :conditions => {:method => :get} do |issues_views|
|
||||
issues_views.connect 'issues', :action => 'index'
|
||||
issues_views.connect 'issues.:format', :action => 'index'
|
||||
issues_views.connect 'projects/:project_id/issues', :action => 'index'
|
||||
issues_views.connect 'projects/:project_id/issues.:format', :action => 'index'
|
||||
issues_views.connect 'projects/:project_id/issues/new', :action => 'new'
|
||||
issues_views.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
|
||||
issues_views.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
|
||||
issues_views.connect 'projects/:project_id/issues/:copy_from/copy', :action => 'new'
|
||||
issues_views.connect 'issues/:id', :action => 'show', :id => /\d+/
|
||||
issues_views.connect 'issues/:id.:format', :action => 'show', :id => /\d+/
|
||||
issues_views.connect 'issues/:id/edit', :action => 'edit', :id => /\d+/
|
||||
end
|
||||
issues_routes.with_options :conditions => {:method => :post} do |issues_actions|
|
||||
issues_actions.connect 'issues', :action => 'index'
|
||||
issues_actions.connect 'projects/:project_id/issues', :action => 'create'
|
||||
issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
|
||||
issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
|
||||
issues_actions.connect 'issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/
|
||||
issues_actions.connect 'issues/:id/:action', :action => /edit|destroy/, :id => /\d+/
|
||||
issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/
|
||||
issues_actions.connect 'issues/bulk_edit', :action => 'bulk_update'
|
||||
end
|
||||
issues_routes.with_options :conditions => {:method => :put} do |issues_actions|
|
||||
issues_actions.connect 'issues/:id/edit', :action => 'update', :id => /\d+/
|
||||
issues_actions.connect 'issues/:id.:format', :action => 'update', :id => /\d+/, :format => /xml/
|
||||
end
|
||||
issues_routes.with_options :conditions => {:method => :delete} do |issues_actions|
|
||||
issues_actions.connect 'issues/:id.:format', :action => 'destroy', :id => /\d+/, :format => /xml/
|
||||
end
|
||||
issues_routes.connect 'issues/gantt', :controller => 'gantts', :action => 'show'
|
||||
issues_routes.connect 'issues/calendar', :controller => 'calendars', :action => 'show'
|
||||
issues_routes.connect 'issues/:action'
|
||||
end
|
||||
|
||||
map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
|
||||
relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
|
||||
relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
|
||||
end
|
||||
map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update]
|
||||
map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update]
|
||||
map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update]
|
||||
map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update]
|
||||
|
||||
map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
|
||||
reports.connect 'projects/:id/issues/report', :action => 'issue_report'
|
||||
reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
|
||||
end
|
||||
|
||||
# Following two routes conflict with the resources because #index allows POST
|
||||
map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
|
||||
map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
|
||||
|
||||
map.resources :issues, :member => { :edit => :post }, :collection => {}
|
||||
map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post }
|
||||
|
||||
map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
|
||||
relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
|
||||
relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
|
||||
end
|
||||
|
||||
map.with_options :controller => 'news' do |news_routes|
|
||||
news_routes.with_options :conditions => {:method => :get} do |news_views|
|
||||
news_views.connect 'news', :action => 'index'
|
||||
|
@ -203,6 +184,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
project_views.connect 'projects/:id/files', :action => 'list_files'
|
||||
project_views.connect 'projects/:id/files/new', :action => 'add_file'
|
||||
project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
|
||||
project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new'
|
||||
end
|
||||
|
||||
projects.with_options :action => 'activity', :conditions => {:method => :get} do |activity|
|
||||
|
|
|
@ -137,11 +137,11 @@ Redmine::AccessControl.map do |map|
|
|||
end
|
||||
|
||||
map.project_module :calendar do |map|
|
||||
map.permission :view_calendar, :calendars => :show
|
||||
map.permission :view_calendar, :calendars => [:show, :update]
|
||||
end
|
||||
|
||||
map.project_module :gantt do |map|
|
||||
map.permission :view_gantt, :gantts => :show
|
||||
map.permission :view_gantt, :gantts => [:show, :update]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class ContextMenusControllerTest < ActionController::TestCase
|
|||
:attributes => { :href => '/issues/1/edit',
|
||||
:class => 'icon-edit' }
|
||||
assert_tag :tag => 'a', :content => 'Closed',
|
||||
:attributes => { :href => '/issues/1/edit?issue%5Bstatus_id%5D=5',
|
||||
:attributes => { :href => '/issues/1?issue%5Bstatus_id%5D=5',
|
||||
:class => '' }
|
||||
assert_tag :tag => 'a', :content => 'Immediate',
|
||||
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&issue%5Bpriority_id%5D=8',
|
||||
|
|
|
@ -69,7 +69,7 @@ class IssuesTest < ActionController::IntegrationTest
|
|||
log_user('jsmith', 'jsmith')
|
||||
set_tmp_attachments_directory
|
||||
|
||||
put 'issues/1/edit',
|
||||
put 'issues/1',
|
||||
:notes => 'Some notes',
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
|
||||
assert_redirected_to "issues/1"
|
||||
|
|
|
@ -91,14 +91,14 @@ class RoutingTest < ActionController::IntegrationTest
|
|||
should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
|
||||
|
||||
should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
|
||||
should_route :post, "/issues/calendar", :controller => 'calendars', :action => 'show'
|
||||
should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update'
|
||||
should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
|
||||
should_route :post, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
|
||||
should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name'
|
||||
|
||||
should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
|
||||
should_route :post, "/issues/gantt", :controller => 'gantts', :action => 'show'
|
||||
should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update'
|
||||
should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
|
||||
should_route :post, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
|
||||
should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name'
|
||||
|
||||
should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
|
||||
|
||||
|
|
Loading…
Reference in New Issue