Resourcified issue statuses.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7890 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-11-22 22:04:07 +00:00
parent 35e8f0d25d
commit 68f3e91bd7
7 changed files with 25 additions and 37 deletions

View File

@ -22,9 +22,6 @@ class IssueStatusesController < ApplicationController
before_filter :require_admin_or_api_request, :only => :index
accept_api_auth :index
verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
:redirect_to => { :action => :index }
def index
respond_to do |format|
format.html {
@ -43,7 +40,7 @@ class IssueStatusesController < ApplicationController
def create
@issue_status = IssueStatus.new(params[:issue_status])
if @issue_status.save
if request.post? && @issue_status.save
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index'
else
@ -57,7 +54,7 @@ class IssueStatusesController < ApplicationController
def update
@issue_status = IssueStatus.find(params[:id])
if @issue_status.update_attributes(params[:issue_status])
if request.put? && @issue_status.update_attributes(params[:issue_status])
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'index'
else
@ -65,6 +62,7 @@ class IssueStatusesController < ApplicationController
end
end
verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index }
def destroy
IssueStatus.find(params[:id]).destroy
redirect_to :action => 'index'
@ -74,7 +72,7 @@ class IssueStatusesController < ApplicationController
end
def update_issue_done_ratio
if IssueStatus.update_issue_done_ratios
if request.post? && IssueStatus.update_issue_done_ratios
flash[:notice] = l(:notice_issue_done_ratios_updated)
else
flash[:error] = l(:error_issue_done_ratios_not_updated)

View File

@ -1,22 +1,12 @@
<%= error_messages_for 'issue_status' %>
<div class="box">
<!--[form:issue_status]-->
<p><label for="issue_status_name"><%=l(:field_name)%><span class="required"> *</span></label>
<%= text_field 'issue_status', 'name' %></p>
<div class="box tabular">
<p><%= f.text_field :name, :required => true %></p>
<% if Issue.use_status_for_done_ratio? %>
<p><label for="issue_done_ratio"><%=l(:field_done_ratio)%></label>
<%= select 'issue_status', :default_done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :include_blank => true %></p>
<p><%= f.select :default_done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :include_blank => true, :label => :field_done_ratio %></p>
<% end %>
<p><label for="issue_status_is_closed"><%=l(:field_is_closed)%></label>
<%= check_box 'issue_status', 'is_closed' %></p>
<p><label for="issue_status_is_default"><%=l(:field_is_default)%></label>
<%= check_box 'issue_status', 'is_default' %></p>
<p><%= f.check_box :is_closed %></p>
<p><%= f.check_box :is_default %></p>
<%= call_hook(:view_issue_statuses_form, :issue_status => @issue_status) %>
<!--[eoform:issue_status]-->
</div>

View File

@ -1,6 +1,6 @@
<h2><%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses', :action => 'index' %> &#187; <%=h @issue_status %></h2>
<h2><%= link_to l(:label_issue_status_plural), issue_statuses_path %> &#187; <%=h @issue_status %></h2>
<% form_tag({:action => 'update', :id => @issue_status}, :class => "tabular") do %>
<%= render :partial => 'form' %>
<% form_for @issue_status, :builder => TabularFormBuilder do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_save) %>
<% end %>

View File

@ -1,6 +1,6 @@
<div class="contextual">
<%= link_to l(:label_issue_status_new), {:action => 'new'}, :class => 'icon icon-add' %>
<%= link_to(l(:label_update_issue_done_ratios), {:action => 'update_issue_done_ratio'}, :class => 'icon icon-multiple', :method => 'post', :confirm => l(:text_are_you_sure)) if Issue.use_status_for_done_ratio? %>
<%= link_to l(:label_issue_status_new), new_issue_status_path, :class => 'icon icon-add' %>
<%= link_to(l(:label_update_issue_done_ratios), update_issue_done_ratio_issue_statuses_path, :class => 'icon icon-multiple', :method => 'post', :confirm => l(:text_are_you_sure)) if Issue.use_status_for_done_ratio? %>
</div>
<h2><%=l(:label_issue_status_plural)%></h2>
@ -19,16 +19,16 @@
<tbody>
<% for status in @issue_statuses %>
<tr class="<%= cycle("odd", "even") %>">
<td><%= link_to h(status.name), :action => 'edit', :id => status %></td>
<td><%= link_to h(status.name), edit_issue_status_path(status) %></td>
<% if Issue.use_status_for_done_ratio? %>
<td align="center"><%= h status.default_done_ratio %></td>
<% end %>
<td align="center"><%= checked_image status.is_default? %></td>
<td align="center"><%= checked_image status.is_closed? %></td>
<td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}) %></td>
<td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}, :put) %></td>
<td class="buttons">
<%= link_to(l(:button_delete), { :action => 'destroy', :id => status },
:method => :post,
<%= link_to(l(:button_delete), issue_status_path(status),
:method => :delete,
:confirm => l(:text_are_you_sure),
:class => 'icon icon-del') %>
</td>

View File

@ -1,6 +1,6 @@
<h2><%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses', :action => 'index' %> &#187; <%=l(:label_issue_status_new)%></h2>
<h2><%= link_to l(:label_issue_status_plural), issue_statuses_path %> &#187; <%=l(:label_issue_status_new)%></h2>
<% form_tag({:action => 'create'}, :class => "tabular") do %>
<%= render :partial => 'form' %>
<% form_for @issue_status, :builder => TabularFormBuilder do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_create) %>
<% end %>

View File

@ -223,9 +223,9 @@ ActionController::Routing::Routes.draw do |map|
map.resources :groups
map.resources :trackers, :except => :show
map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
#left old routes at the bottom for backwards compat
map.connect 'issue_statuses.:format', :controller => 'issue_statuses', :action => 'index'
map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'

View File

@ -56,7 +56,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
end
def test_update
post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
put :update, :id => '3', :issue_status => {:name => 'Renamed status'}
assert_redirected_to :action => 'index'
status = IssueStatus.find(3)
assert_equal 'Renamed status', status.name
@ -66,7 +66,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
Issue.delete_all("status_id = 1")
assert_difference 'IssueStatus.count', -1 do
post :destroy, :id => '1'
delete :destroy, :id => '1'
end
assert_redirected_to :action => 'index'
assert_nil IssueStatus.find_by_id(1)
@ -76,7 +76,7 @@ class IssueStatusesControllerTest < ActionController::TestCase
assert_not_nil Issue.find_by_status_id(1)
assert_no_difference 'IssueStatus.count' do
post :destroy, :id => '1'
delete :destroy, :id => '1'
end
assert_redirected_to :action => 'index'
assert_not_nil IssueStatus.find_by_id(1)