diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 1115691a1..febacd075 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -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 diff --git a/app/controllers/gantts_controller.rb b/app/controllers/gantts_controller.rb index cdfef5238..6a6071e86 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/gantts_controller.rb @@ -43,4 +43,8 @@ class GanttsController < ApplicationController end end + def update + show + end + end diff --git a/app/views/calendars/show.html.erb b/app/views/calendars/show.html.erb index 4541cc0c8..afbceb9cd 100644 --- a/app/views/calendars/show.html.erb +++ b/app/views/calendars/show.html.erb @@ -1,6 +1,7 @@

<%= l(:label_calendar) %>

-<% 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%>
<%= l(:label_filter_plural) %>
diff --git a/app/views/gantts/show.html.erb b/app/views/gantts/show.html.erb index 653a41d41..5d4ef0dbf 100644 --- a/app/views/gantts/show.html.erb +++ b/app/views/gantts/show.html.erb @@ -1,6 +1,7 @@

<%= l(:label_gantt) %>

-<% 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%>
<%= l(:label_filter_plural) %>
diff --git a/config/routes.rb b/config/routes.rb index 4e1f9d7d5..ea5112216 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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.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' + 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.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 => '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 - 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| diff --git a/lib/redmine.rb b/lib/redmine.rb index e1f1e2e16..69b7b7a94 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -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 diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb index eee9dc608..764350879 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/context_menus_controller_test.rb @@ -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', diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index 0c1a36d34..c8a151cfd 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -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" diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 119b506ae..9b5f39399 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -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'