@@ -0,0 +1,9 | |||
|
1 | class ChangeIssueCategoriesNameLimitTo60 < ActiveRecord::Migration | |
|
2 | def self.up | |
|
3 | change_column :issue_categories, :name, :string, :limit => 60, :default => "", :null => false | |
|
4 | end | |
|
5 | ||
|
6 | def self.down | |
|
7 | change_column :issue_categories, :name, :string, :limit => 30, :default => "", :null => false | |
|
8 | end | |
|
9 | end |
@@ -1,49 +1,49 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2015 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class IssueCategory < ActiveRecord::Base |
|
19 | 19 | include Redmine::SafeAttributes |
|
20 | 20 | belongs_to :project |
|
21 | 21 | belongs_to :assigned_to, :class_name => 'Principal' |
|
22 | 22 | has_many :issues, :foreign_key => 'category_id', :dependent => :nullify |
|
23 | 23 | |
|
24 | 24 | validates_presence_of :name |
|
25 | 25 | validates_uniqueness_of :name, :scope => [:project_id] |
|
26 |
validates_length_of :name, :maximum => |
|
|
26 | validates_length_of :name, :maximum => 60 | |
|
27 | 27 | attr_protected :id |
|
28 | 28 | |
|
29 | 29 | safe_attributes 'name', 'assigned_to_id' |
|
30 | 30 | |
|
31 | 31 | scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)} |
|
32 | 32 | |
|
33 | 33 | alias :destroy_without_reassign :destroy |
|
34 | 34 | |
|
35 | 35 | # Destroy the category |
|
36 | 36 | # If a category is specified, issues are reassigned to this category |
|
37 | 37 | def destroy(reassign_to = nil) |
|
38 | 38 | if reassign_to && reassign_to.is_a?(IssueCategory) && reassign_to.project == self.project |
|
39 | 39 | Issue.where({:category_id => id}).update_all({:category_id => reassign_to.id}) |
|
40 | 40 | end |
|
41 | 41 | destroy_without_reassign |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | 44 | def <=>(category) |
|
45 | 45 | name <=> category.name |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def to_s; name end |
|
49 | 49 | end |
@@ -1,6 +1,6 | |||
|
1 | 1 | <%= error_messages_for 'category' %> |
|
2 | 2 | |
|
3 | 3 | <div class="box tabular"> |
|
4 |
<p><%= f.text_field :name, :size => |
|
|
4 | <p><%= f.text_field :name, :size => 60, :required => true %></p> | |
|
5 | 5 | <p><%= f.select :assigned_to_id, principals_options_for_select(@project.assignable_users, @category.assigned_to), :include_blank => true %></p> |
|
6 | 6 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now