##// END OF EJS Templates
Allow longer version names (#711, closes #712)....
Jean-Philippe Lang -
r1206:66594d46b20d
parent child
Show More
@@ -0,0 +1,9
1 class ChangeVersionsNameLimit < ActiveRecord::Migration
2 def self.up
3 change_column :versions, :name, :string, :limit => nil
4 end
5
6 def self.down
7 change_column :versions, :name, :string, :limit => 30
8 end
9 end
@@ -1,106 +1,106
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 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 Version < ActiveRecord::Base
19 19 before_destroy :check_integrity
20 20 belongs_to :project
21 21 has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
22 22 has_many :attachments, :as => :container, :dependent => :destroy
23 23
24 24 validates_presence_of :name
25 25 validates_uniqueness_of :name, :scope => [:project_id]
26 validates_length_of :name, :maximum => 30
26 validates_length_of :name, :maximum => 60
27 27 validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true
28 28
29 29 def start_date
30 30 effective_date
31 31 end
32 32
33 33 def due_date
34 34 effective_date
35 35 end
36 36
37 37 # Returns the total estimated time for this version
38 38 def estimated_hours
39 39 @estimated_hours ||= fixed_issues.sum(:estimated_hours).to_f
40 40 end
41 41
42 42 # Returns the total reported time for this version
43 43 def spent_hours
44 44 @spent_hours ||= TimeEntry.sum(:hours, :include => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
45 45 end
46 46
47 47 # Returns true if the version is completed: due date reached and no open issues
48 48 def completed?
49 49 effective_date && (effective_date <= Date.today) && (open_issues_count == 0)
50 50 end
51 51
52 52 def completed_pourcent
53 53 if fixed_issues.count == 0
54 54 0
55 55 elsif open_issues_count == 0
56 56 100
57 57 else
58 58 (closed_issues_count * 100 + Issue.sum('done_ratio', :include => 'status', :conditions => ["fixed_version_id = ? AND is_closed = ?", id, false]).to_f) / fixed_issues.count
59 59 end
60 60 end
61 61
62 62 def closed_pourcent
63 63 if fixed_issues.count == 0
64 64 0
65 65 else
66 66 closed_issues_count * 100.0 / fixed_issues.count
67 67 end
68 68 end
69 69
70 70 # Returns true if the version is overdue: due date reached and some open issues
71 71 def overdue?
72 72 effective_date && (effective_date < Date.today) && (open_issues_count > 0)
73 73 end
74 74
75 75 def open_issues_count
76 76 @open_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, false], :include => :status)
77 77 end
78 78
79 79 def closed_issues_count
80 80 @closed_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, true], :include => :status)
81 81 end
82 82
83 83 def wiki_page
84 84 if project.wiki && !wiki_page_title.blank?
85 85 @wiki_page ||= project.wiki.find_page(wiki_page_title)
86 86 end
87 87 @wiki_page
88 88 end
89 89
90 90 def to_s; name end
91 91
92 92 # Versions are sorted by effective_date
93 93 # Those with no effective_date are at the end, sorted by name
94 94 def <=>(version)
95 95 if self.effective_date
96 96 version.effective_date ? (self.effective_date <=> version.effective_date) : -1
97 97 else
98 98 version.effective_date ? 1 : (self.name <=> version.name)
99 99 end
100 100 end
101 101
102 102 private
103 103 def check_integrity
104 104 raise "Can't delete version" if self.fixed_issues.find(:first)
105 105 end
106 106 end
@@ -1,15 +1,15
1 1 <%= error_messages_for 'version' %>
2 2
3 3 <div class="box">
4 <p><%= f.text_field :name, :size => 20, :required => true %></p>
4 <p><%= f.text_field :name, :size => 60, :required => true %></p>
5 5 <p><%= f.text_field :description, :size => 60 %></p>
6 6 <p><%= f.text_field :wiki_page_title, :label => :label_wiki_page, :size => 60, :disabled => @project.wiki.nil? %></p>
7 7 <p><%= f.text_field :effective_date, :size => 10 %><%= calendar_for('version_effective_date') %></p>
8 8 </div>
9 9
10 10 <% content_for :header_tags do %>
11 11 <%= javascript_include_tag 'calendar/calendar' %>
12 12 <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
13 13 <%= javascript_include_tag 'calendar/calendar-setup' %>
14 14 <%= stylesheet_link_tag 'calendar' %>
15 15 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now