Project

General

Profile

Patch #1666 » explicit_version_completion.patch

Peter Van den Bosch, 2008-07-21 00:50

View differences:

app/models/issue.rb (working copy)
113 113
    if start_date && soonest_start && start_date < soonest_start
114 114
      errors.add :start_date, :activerecord_error_invalid
115 115
    end
116
    
117
    if fixed_version && !closed? && fixed_version.completed?
118
      errors.add :fixed_version, :activerecord_error_version_completed
119
    end
116 120
  end
117 121
  
118 122
  def validate_on_create
app/models/version.rb (working copy)
26 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
  def validate
30
    if completed? && open_issues_count > 0
31
      errors.add :completed, :activerecord_error_open_issues
32
    end
33
  end
34
  
29 35
  def start_date
30 36
    effective_date
31 37
  end
......
44 50
    @spent_hours ||= TimeEntry.sum(:hours, :include => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
45 51
  end
46 52
  
47
  # Returns true if the version is completed: due date reached and no open issues
48
  def completed?
49
    effective_date && (effective_date <= Date.today) && (open_issues_count == 0)
50
  end
51
  
52 53
  def completed_pourcent
53 54
    if fixed_issues.count == 0
54 55
      0
......
69 70
  
70 71
  # Returns true if the version is overdue: due date reached and some open issues
71 72
  def overdue?
72
    effective_date && (effective_date < Date.today) && (open_issues_count > 0)
73
    effective_date && (effective_date < Date.today) && (!self.completed?)
73 74
  end
74 75
  
75 76
  def open_issues_count
app/models/project.rb (working copy)
171 171
    children.select {|child| child.active?}
172 172
  end
173 173
  
174
  def incomplete_versions
175
    versions.reject(&:completed?).sort
176
  end
177
  
174 178
  # Returns an array of the trackers used by the project and its sub projects
175 179
  def rolled_up_trackers
176 180
    @rolled_up_trackers ||=
app/controllers/projects_controller.rb (working copy)
213 213
  def roadmap
214 214
    @trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true])
215 215
    retrieve_selected_tracker_ids(@trackers)
216
    @versions = @project.versions.sort
217
    @versions = @versions.select {|v| !v.completed? } unless params[:completed]
216
    @versions = params[:completed] ? @project.versions.sort : @project.incomplete_versions
218 217
  end
219 218
  
220 219
  def activity
app/views/versions/_form.rhtml (working copy)
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
<p><%= f.check_box :completed, :label => :label_completed_version %>
8 9
</div>
app/views/issues/_form.rhtml (working copy)
30 30
                     {:controller => 'projects', :action => 'add_issue_category', :id => @project},
31 31
                     :class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p>
32 32
<%= content_tag('p', f.select(:fixed_version_id, 
33
                              (@project.versions.sort.collect {|v| [v.name, v.id]}),
34
                              { :include_blank => true })) unless @project.versions.empty? %>
33
                              (@project.incomplete_versions.collect {|v| [v.name, v.id]}),
34
                              { :include_blank => true })) unless @project.incomplete_versions.empty? %>
35 35
</div>
36 36

  
37 37
<div class="splitcontentright">
app/views/issues/bulk_edit.rhtml (working copy)
27 27
<label><%= l(:field_fixed_version) %>: 
28 28
<%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') +
29 29
                                   content_tag('option', l(:label_none), :value => 'none') +
30
                                   options_from_collection_for_select(@project.versions, :id, :name)) %></label>
30
                                   options_from_collection_for_select(@project.incomplete_versions, :id, :name)) %></label>
31 31
</p>
32 32

  
33 33
<p>
app/views/issues/_form_update.rhtml (working copy)
5 5
<div class="splitcontentright">
6 6
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
7 7
<%= content_tag('p', f.select(:fixed_version_id, 
8
                          (@project.versions.sort.collect {|v| [v.name, v.id]}),
9
                          { :include_blank => true })) unless @project.versions.empty? %>
8
                          (@project.incomplete_versions.collect {|v| [v.name, v.id]}),
9
                          { :include_blank => true })) unless @project.incomplete_versions.empty? %>
10 10
</div>
app/views/issues/context_menu.rhtml (working copy)
20 20
		<% end -%>
21 21
		</ul>
22 22
	</li>
23
	<% unless @project.versions.empty? -%>
23
	<% unless @project.incomplete_versions.empty? -%>
24 24
	<li class="folder">			
25 25
		<a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
26 26
		<ul>
27
		<% @project.versions.sort.each do |v| -%>
27
		<% @project.incomplete_versions.each do |v| -%>
28 28
		    <li><%= context_menu_link v.name, {:controller => 'issues', :action => 'edit', :id => @issue, 'issue[fixed_version_id]' => v, :back_to => @back}, :method => :post,
29 29
		                              :selected => (v == @issue.fixed_version), :disabled => !@can[:update] %></li>
30 30
		<% end -%>
lang/en.yml (working copy)
35 35
activerecord_error_greater_than_start_date: must be greater than start date
36 36
activerecord_error_not_same_project: doesn't belong to the same project
37 37
activerecord_error_circular_dependency: This relation would create a circular dependency
38
activerecord_error_version_completed: is a completed version
39
activerecord_error_open_issues: There are still open issues
38 40

  
39 41
general_fmt_age: %d yr
40 42
general_fmt_age_plural: %d yrs
......
464 466
label_stay_logged_in: Stay logged in
465 467
label_disabled: disabled
466 468
label_show_completed_versions: Show completed versions
469
label_completed_version: Completed
467 470
label_me: me
468 471
label_board: Forum
469 472
label_board_new: New forum
lang/fr.yml (working copy)
35 35
activerecord_error_greater_than_start_date: doit être postérieur à la date de début
36 36
activerecord_error_not_same_project: n'appartient pas au même projet
37 37
activerecord_error_circular_dependency: Cette relation créerait une dépendance circulaire
38
activerecord_error_version_completed: est une version complétée
39
activerecord_error_open_issues: Il reste encore des demandes ouvertes
38 40

  
39 41
general_fmt_age: %d an
40 42
general_fmt_age_plural: %d ans
......
464 466
label_stay_logged_in: Rester connecté
465 467
label_disabled: désactivé
466 468
label_show_completed_versions: Voir les versions passées
469
label_completed_version: Complété
467 470
label_me: moi
468 471
label_board: Forum
469 472
label_board_new: Nouveau forum
lang/nl.yml (working copy)
35 35
activerecord_error_greater_than_start_date: moet hoger zijn dan startdatum
36 36
activerecord_error_not_same_project: hoort niet bij hetzelfde project
37 37
activerecord_error_circular_dependency: Deze relatie zou een circulaire afhankelijkheid tot gevolg hebben
38
activerecord_error_version_completed: is een afgeronde versie
39
activerecord_error_open_issues: Er zijn nog open issues
38 40

  
39 41
general_fmt_age: %d jr
40 42
general_fmt_age_plural: %d jr
......
403 405
label_stay_logged_in: Blijf ingelogd
404 406
label_disabled: uitgeschakeld
405 407
label_show_completed_versions: Toon afgeronde versies
408
label_completed_version: Voltooid
406 409
label_me: ik
407 410
label_board: Forum
408 411
label_board_new: Nieuw forum
db/migrate/095_add_versions_completed_status.rb (revision 0)
1
class AddVersionsCompletedStatus < ActiveRecord::Migration
2
  def self.up
3
    add_column :versions, :completed, :boolean, :default => false
4
  end
5

  
6
  def self.down
7
    remove_column :versions, :completed
8
  end
9
end
(1-1/3)