Each category can now be associated to a user, so that new issues in that category are automatically assigned to that user.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@577 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f816d4f378
commit
87bad767c6
|
@ -165,17 +165,12 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
# Add a new issue category to @project
|
# Add a new issue category to @project
|
||||||
def add_issue_category
|
def add_issue_category
|
||||||
if request.post?
|
@category = @project.issue_categories.build(params[:category])
|
||||||
@issue_category = @project.issue_categories.build(params[:issue_category])
|
if request.post? and @category.save
|
||||||
if @issue_category.save
|
flash[:notice] = l(:notice_successful_create)
|
||||||
flash[:notice] = l(:notice_successful_create)
|
redirect_to :action => 'settings', :tab => 'categories', :id => @project
|
||||||
redirect_to :action => 'settings', :tab => 'categories', :id => @project
|
|
||||||
else
|
|
||||||
settings
|
|
||||||
render :action => 'settings'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new version to @project
|
# Add a new version to @project
|
||||||
def add_version
|
def add_version
|
||||||
|
|
|
@ -60,6 +60,13 @@ class Issue < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def before_create
|
||||||
|
# default assignment based on category
|
||||||
|
if assigned_to.nil? && category && category.assigned_to
|
||||||
|
self.assigned_to = category.assigned_to
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def before_save
|
def before_save
|
||||||
if @current_journal
|
if @current_journal
|
||||||
# attributes changes
|
# attributes changes
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
class IssueCategory < ActiveRecord::Base
|
class IssueCategory < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name, :scope => [:project_id]
|
validates_uniqueness_of :name, :scope => [:project_id]
|
||||||
|
|
|
@ -26,4 +26,9 @@ class Member < ActiveRecord::Base
|
||||||
def name
|
def name
|
||||||
self.user.display_name
|
self.user.display_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def before_destroy
|
||||||
|
# remove category based auto assignments for this member
|
||||||
|
project.issue_categories.update_all "assigned_to_id = NULL", ["assigned_to_id = ?", self.user.id]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}", :order => "#{Project.table_name}.name", :dependent => :delete_all
|
has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}", :order => "#{Project.table_name}.name", :dependent => :delete_all
|
||||||
has_many :projects, :through => :memberships
|
has_many :projects, :through => :memberships
|
||||||
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
has_many :custom_values, :dependent => :delete_all, :as => :customized
|
||||||
|
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||||
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
|
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
|
||||||
has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'"
|
has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'"
|
||||||
belongs_to :auth_source
|
belongs_to :auth_source
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<%= error_messages_for 'issue_category' %>
|
<%= error_messages_for 'category' %>
|
||||||
|
|
||||||
<!--[form:issue_category]-->
|
|
||||||
<p><label for="issue_category_name"><%l(:field_name)%></label>
|
|
||||||
<%= text_field 'issue_category', 'name' %></p>
|
|
||||||
<!--[eoform:issue_category]-->
|
|
||||||
|
|
||||||
|
<div class="box">
|
||||||
|
<p><%= f.text_field :name, :size => 30, :required => true %></p>
|
||||||
|
<p><%= f.select :assigned_to_id, @project.users.collect{|u| [u.name, u.id]}, :include_blank => true %></p>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<h2><%=l(:label_issue_category)%></h2>
|
<h2><%=l(:label_issue_category)%></h2>
|
||||||
|
|
||||||
<% form_tag({:action => 'edit', :id => @category}, :class => "tabular") do %>
|
<% labelled_tabular_form_for :category, @category, :url => { :action => 'edit', :id => @category } do |f| %>
|
||||||
<%= render :partial => 'form' %>
|
<%= render :partial => 'issue_categories/form', :locals => { :f => f } %>
|
||||||
<%= submit_tag l(:button_save) %>
|
<%= submit_tag l(:button_create) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<h2><%=l(:label_issue_category_new)%></h2>
|
||||||
|
|
||||||
|
<% labelled_tabular_form_for :category, @category, :url => { :action => 'add_issue_category' } do |f| %>
|
||||||
|
<%= render :partial => 'issue_categories/form', :locals => { :f => f } %>
|
||||||
|
<%= submit_tag l(:button_create) %>
|
||||||
|
<% end %>
|
|
@ -53,36 +53,27 @@
|
||||||
|
|
||||||
<div id="tab-content-categories" class="tab-content" style="display:none;">
|
<div id="tab-content-categories" class="tab-content" style="display:none;">
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead><th><%= l(:label_issue_category) %></th><th style="width:15%"></th></thead>
|
<thead>
|
||||||
|
<th><%= l(:label_issue_category) %></th>
|
||||||
|
<th><%= l(:field_assigned_to) %></th>
|
||||||
|
<th style="width:15%"></th>
|
||||||
|
<th style="width:15%"></th>
|
||||||
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% for @category in @project.issue_categories %>
|
<% for category in @project.issue_categories %>
|
||||||
<% unless @category.new_record? %>
|
<% unless category.new_record? %>
|
||||||
<tr class="<%= cycle 'odd', 'even' %>">
|
<tr class="<%= cycle 'odd', 'even' %>">
|
||||||
<td>
|
<td><%=h(category.name) %></td>
|
||||||
<% form_tag({:controller => 'issue_categories', :action => 'edit', :id => @category}) do %>
|
<td><%=h(category.assigned_to.name) if category.assigned_to %></td>
|
||||||
<%= text_field 'category', 'name', :size => 25 %>
|
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'issue_categories', :action => 'edit', :id => category }, :class => 'icon icon-edit' %></small></td>
|
||||||
<% if authorize_for('issue_categories', 'edit') %>
|
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'issue_categories', :action => 'destroy', :id => category}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td>
|
||||||
<%= submit_tag l(:button_save), :class => "button-small" %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<td align="center">
|
|
||||||
<small><%= link_to_if_authorized l(:button_delete), {:controller => 'issue_categories', :action => 'destroy', :id => @category}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<% if authorize_for('projects', 'add_issue_category') %>
|
<p><%= link_to_if_authorized l(:label_issue_category_new), :controller => 'projects', :action => 'add_issue_category', :id => @project %></p>
|
||||||
<% form_tag({:action => 'add_issue_category', :tab => 'categories', :id => @project}) do %>
|
|
||||||
<p><label for="issue_category_name"><%=l(:label_issue_category_new)%></label><br />
|
|
||||||
<%= error_messages_for 'issue_category' %>
|
|
||||||
<%= text_field 'issue_category', 'name', :size => 25 %>
|
|
||||||
<%= submit_tag l(:button_add) %></p>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="tab-content-boards" class="tab-content" style="display:none;">
|
<div id="tab-content-boards" class="tab-content" style="display:none;">
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class AddIssueCategoriesAssignedToId < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :issue_categories, :assigned_to_id, :integer
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :issue_categories, :assigned_to_id
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,8 +2,10 @@
|
||||||
issue_categories_001:
|
issue_categories_001:
|
||||||
name: Printing
|
name: Printing
|
||||||
project_id: 1
|
project_id: 1
|
||||||
|
assigned_to_id: 2
|
||||||
id: 1
|
id: 1
|
||||||
issue_categories_002:
|
issue_categories_002:
|
||||||
name: Recipes
|
name: Recipes
|
||||||
project_id: 1
|
project_id: 1
|
||||||
|
assigned_to_id:
|
||||||
id: 2
|
id: 2
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
# redMine - project management software
|
||||||
|
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
|
class IssueTest < Test::Unit::TestCase
|
||||||
|
fixtures :projects, :users, :members, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues
|
||||||
|
|
||||||
|
def test_category_based_assignment
|
||||||
|
issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
|
||||||
|
assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue