@@ -0,0 +1,6 | |||||
|
1 | <h2><%=l(:label_issue_category_new)%></h2> | |||
|
2 | ||||
|
3 | <% labelled_tabular_form_for :category, @category, :url => { :action => 'add_issue_category' } do |f| %> | |||
|
4 | <%= render :partial => 'issue_categories/form', :locals => { :f => f } %> | |||
|
5 | <%= submit_tag l(:button_create) %> | |||
|
6 | <% end %> |
@@ -0,0 +1,9 | |||||
|
1 | class AddIssueCategoriesAssignedToId < ActiveRecord::Migration | |||
|
2 | def self.up | |||
|
3 | add_column :issue_categories, :assigned_to_id, :integer | |||
|
4 | end | |||
|
5 | ||||
|
6 | def self.down | |||
|
7 | remove_column :issue_categories, :assigned_to_id | |||
|
8 | end | |||
|
9 | end |
@@ -0,0 +1,27 | |||||
|
1 | # redMine - project management software | |||
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |||
|
3 | # | |||
|
4 | # This program is free software; you can redistribute it and/or | |||
|
5 | # modify it under the terms of the GNU General Public License | |||
|
6 | # as published by the Free Software Foundation; either version 2 | |||
|
7 | # of the License, or (at your option) any later version. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU General Public License | |||
|
15 | # along with this program; if not, write to the Free Software | |||
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
17 | ||||
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |||
|
19 | ||||
|
20 | class IssueTest < Test::Unit::TestCase | |||
|
21 | fixtures :projects, :users, :members, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues | |||
|
22 | ||||
|
23 | def test_category_based_assignment | |||
|
24 | 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) | |||
|
25 | assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to | |||
|
26 | end | |||
|
27 | end |
@@ -165,17 +165,12 class ProjectsController < ApplicationController | |||||
165 |
|
165 | |||
166 | # Add a new issue category to @project |
|
166 | # Add a new issue category to @project | |
167 | def add_issue_category |
|
167 | def add_issue_category | |
168 | if request.post? |
|
168 | @category = @project.issue_categories.build(params[:category]) | |
169 | @issue_category = @project.issue_categories.build(params[:issue_category]) |
|
169 | if request.post? and @category.save | |
170 | if @issue_category.save |
|
170 | flash[:notice] = l(:notice_successful_create) | |
171 | flash[:notice] = l(:notice_successful_create) |
|
171 | redirect_to :action => 'settings', :tab => 'categories', :id => @project | |
172 | redirect_to :action => 'settings', :tab => 'categories', :id => @project |
|
|||
173 | else |
|
|||
174 | settings |
|
|||
175 | render :action => 'settings' |
|
|||
176 | end |
|
|||
177 | end |
|
172 | end | |
178 |
end |
|
173 | end | |
179 |
|
174 | |||
180 | # Add a new version to @project |
|
175 | # Add a new version to @project | |
181 | def add_version |
|
176 | def add_version |
@@ -60,6 +60,13 class Issue < ActiveRecord::Base | |||||
60 | end |
|
60 | end | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
|
63 | def before_create | |||
|
64 | # default assignment based on category | |||
|
65 | if assigned_to.nil? && category && category.assigned_to | |||
|
66 | self.assigned_to = category.assigned_to | |||
|
67 | end | |||
|
68 | end | |||
|
69 | ||||
63 | def before_save |
|
70 | def before_save | |
64 | if @current_journal |
|
71 | if @current_journal | |
65 | # attributes changes |
|
72 | # attributes changes |
@@ -18,6 +18,7 | |||||
18 | class IssueCategory < ActiveRecord::Base |
|
18 | class IssueCategory < ActiveRecord::Base | |
19 | before_destroy :check_integrity |
|
19 | before_destroy :check_integrity | |
20 | belongs_to :project |
|
20 | belongs_to :project | |
|
21 | belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id' | |||
21 |
|
22 | |||
22 | validates_presence_of :name |
|
23 | validates_presence_of :name | |
23 | validates_uniqueness_of :name, :scope => [:project_id] |
|
24 | validates_uniqueness_of :name, :scope => [:project_id] |
@@ -26,4 +26,9 class Member < ActiveRecord::Base | |||||
26 | def name |
|
26 | def name | |
27 | self.user.display_name |
|
27 | self.user.display_name | |
28 | end |
|
28 | end | |
|
29 | ||||
|
30 | def before_destroy | |||
|
31 | # remove category based auto assignments for this member | |||
|
32 | project.issue_categories.update_all "assigned_to_id = NULL", ["assigned_to_id = ?", self.user.id] | |||
|
33 | end | |||
29 | end |
|
34 | end |
@@ -26,6 +26,7 class User < ActiveRecord::Base | |||||
26 | 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 |
|
26 | 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 | |
27 | has_many :projects, :through => :memberships |
|
27 | has_many :projects, :through => :memberships | |
28 | has_many :custom_values, :dependent => :delete_all, :as => :customized |
|
28 | has_many :custom_values, :dependent => :delete_all, :as => :customized | |
|
29 | has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify | |||
29 | has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' |
|
30 | has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' | |
30 | has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'" |
|
31 | has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'" | |
31 | belongs_to :auth_source |
|
32 | belongs_to :auth_source |
@@ -1,7 +1,6 | |||||
1 |
<%= error_messages_for ' |
|
1 | <%= error_messages_for 'category' %> | |
2 |
|
||||
3 | <!--[form:issue_category]--> |
|
|||
4 | <p><label for="issue_category_name"><%l(:field_name)%></label> |
|
|||
5 | <%= text_field 'issue_category', 'name' %></p> |
|
|||
6 | <!--[eoform:issue_category]--> |
|
|||
7 |
|
2 | |||
|
3 | <div class="box"> | |||
|
4 | <p><%= f.text_field :name, :size => 30, :required => true %></p> | |||
|
5 | <p><%= f.select :assigned_to_id, @project.users.collect{|u| [u.name, u.id]}, :include_blank => true %></p> | |||
|
6 | </div> |
@@ -1,6 +1,6 | |||||
1 | <h2><%=l(:label_issue_category)%></h2> |
|
1 | <h2><%=l(:label_issue_category)%></h2> | |
2 |
|
2 | |||
3 | <% form_tag({:action => 'edit', :id => @category}, :class => "tabular") do %> |
|
3 | <% labelled_tabular_form_for :category, @category, :url => { :action => 'edit', :id => @category } do |f| %> | |
4 | <%= render :partial => 'form' %> |
|
4 | <%= render :partial => 'issue_categories/form', :locals => { :f => f } %> | |
5 |
|
|
5 | <%= submit_tag l(:button_create) %> | |
6 | <% end %> |
|
6 | <% end %> |
@@ -53,36 +53,27 | |||||
53 |
|
53 | |||
54 | <div id="tab-content-categories" class="tab-content" style="display:none;"> |
|
54 | <div id="tab-content-categories" class="tab-content" style="display:none;"> | |
55 | <table class="list"> |
|
55 | <table class="list"> | |
56 | <thead><th><%= l(:label_issue_category) %></th><th style="width:15%"></th></thead> |
|
56 | <thead> | |
|
57 | <th><%= l(:label_issue_category) %></th> | |||
|
58 | <th><%= l(:field_assigned_to) %></th> | |||
|
59 | <th style="width:15%"></th> | |||
|
60 | <th style="width:15%"></th> | |||
|
61 | </thead> | |||
57 | <tbody> |
|
62 | <tbody> | |
58 |
<% for |
|
63 | <% for category in @project.issue_categories %> | |
59 |
<% unless |
|
64 | <% unless category.new_record? %> | |
60 | <tr class="<%= cycle 'odd', 'even' %>"> |
|
65 | <tr class="<%= cycle 'odd', 'even' %>"> | |
61 | <td> |
|
66 | <td><%=h(category.name) %></td> | |
62 | <% form_tag({:controller => 'issue_categories', :action => 'edit', :id => @category}) do %> |
|
67 | <td><%=h(category.assigned_to.name) if category.assigned_to %></td> | |
63 | <%= text_field 'category', 'name', :size => 25 %> |
|
68 | <td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'issue_categories', :action => 'edit', :id => category }, :class => 'icon icon-edit' %></small></td> | |
64 | <% if authorize_for('issue_categories', 'edit') %> |
|
69 | <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> | |
65 | <%= submit_tag l(:button_save), :class => "button-small" %> |
|
|||
66 | <% end %> |
|
|||
67 | <% end %> |
|
|||
68 | </td> |
|
|||
69 | <td align="center"> |
|
|||
70 | <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> |
|
|||
71 | </td> |
|
|||
72 | </tr> |
|
70 | </tr> | |
73 | <% end %> |
|
71 | <% end %> | |
74 | <% end %> |
|
72 | <% end %> | |
75 | </tbody> |
|
73 | </tbody> | |
76 | </table> |
|
74 | </table> | |
77 | |
|
75 | | |
78 | <% if authorize_for('projects', 'add_issue_category') %> |
|
76 | <p><%= link_to_if_authorized l(:label_issue_category_new), :controller => 'projects', :action => 'add_issue_category', :id => @project %></p> | |
79 | <% form_tag({:action => 'add_issue_category', :tab => 'categories', :id => @project}) do %> |
|
|||
80 | <p><label for="issue_category_name"><%=l(:label_issue_category_new)%></label><br /> |
|
|||
81 | <%= error_messages_for 'issue_category' %> |
|
|||
82 | <%= text_field 'issue_category', 'name', :size => 25 %> |
|
|||
83 | <%= submit_tag l(:button_add) %></p> |
|
|||
84 | <% end %> |
|
|||
85 | <% end %> |
|
|||
86 | </div> |
|
77 | </div> | |
87 |
|
78 | |||
88 | <div id="tab-content-boards" class="tab-content" style="display:none;"> |
|
79 | <div id="tab-content-boards" class="tab-content" style="display:none;"> |
@@ -2,8 +2,10 | |||||
2 | issue_categories_001: |
|
2 | issue_categories_001: | |
3 | name: Printing |
|
3 | name: Printing | |
4 | project_id: 1 |
|
4 | project_id: 1 | |
|
5 | assigned_to_id: 2 | |||
5 | id: 1 |
|
6 | id: 1 | |
6 | issue_categories_002: |
|
7 | issue_categories_002: | |
7 | name: Recipes |
|
8 | name: Recipes | |
8 | project_id: 1 |
|
9 | project_id: 1 | |
|
10 | assigned_to_id: | |||
9 | id: 2 |
|
11 | id: 2 |
General Comments 0
You need to be logged in to leave comments.
Login now