Project

General

Profile

Patch #4274 » 0001-Adds-an-option-which-will-automatically-update-an-is.patch

Eric Davis, 2009-11-23 23:43

View differences:

app/controllers/issue_statuses_controller.rb
18 18
class IssueStatusesController < ApplicationController
19 19
  before_filter :require_admin
20 20

  
21
  verify :method => :post, :only => [ :destroy, :create, :update, :move ],
21
  verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
22 22
         :redirect_to => { :action => :list }
23 23
         
24 24
  def index
......
66 66
    flash[:error] = "Unable to delete issue status"
67 67
    redirect_to :action => 'list'
68 68
  end  	
69
  
70
  def update_issue_done_ratio
71
    if IssueStatus.update_issue_done_ratios
72
      flash[:notice] = l(:notice_issue_done_ratios_updated)
73
    else
74
      flash[:error] =  l(:error_issue_done_ratios_not_updated)
75
    end
76
    redirect_to :action => 'list'
77
  end
69 78
end
app/models/issue.rb
55 55
                                          :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
56 56
  
57 57
  named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status
58
  
58

  
59
  before_save :update_done_ratio_from_issue_status
59 60
  after_save :create_journal
60 61
  
61 62
  # Returns true if usr or current user is allowed to view the issue
......
132 133
    write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h)
133 134
  end
134 135
  
136
  def done_ratio
137
    if Setting.issue_status_for_done_ratio? && !self.status.default_done_ratio.blank?
138
      self.status.default_done_ratio
139
    else
140
      read_attribute(:done_ratio)
141
    end
142
  end
143
  
135 144
  def validate
136 145
    if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
137 146
      errors.add :due_date, :not_a_date
......
165 174
    end
166 175
  end
167 176
  
177
  # Set the done_ratio using the status if that setting is set.  This will keep the done_ratios
178
  # even if the user turns off the setting later
179
  def update_done_ratio_from_issue_status
180
    if Setting.issue_status_for_done_ratio? && !self.status.default_done_ratio.blank?
181
      self.done_ratio = self.status.default_done_ratio
182
    end
183
  end
184
  
168 185
  def after_save
169 186
    # Reload is needed in order to get the right status
170 187
    reload
app/models/issue_status.rb
33 33
  def self.default
34 34
    find(:first, :conditions =>["is_default=?", true])
35 35
  end
36
  
37
  # Update all the +Issues+ setting their done_ratio to the value of their +IssueStatus+
38
  def self.update_issue_done_ratios
39
    if Setting.issue_status_for_done_ratio?
40
      IssueStatus.find(:all, :conditions => ["default_done_ratio >= 0"]).each do |status|
41
        Issue.update_all(["done_ratio = ?", status.default_done_ratio],
42
                         ["status_id = ?", status.id])
43
      end
44
    end
45

  
46
    return Setting.issue_status_for_done_ratio?
47
  end
36 48

  
37 49
  # Returns an array of all statuses the given role can switch to
38 50
  # Uses association cache when called more than one time
app/views/issue_statuses/_form.rhtml
5 5
<p><label for="issue_status_name"><%=l(:field_name)%><span class="required"> *</span></label>
6 6
<%= text_field 'issue_status', 'name'  %></p>
7 7

  
8
<% if Setting.issue_status_for_done_ratio? %>
9
<p><label for="issue_done_ratio"><%=l(:field_done_ratio)%></label>
10
<%= select 'issue_status', :default_done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
11
<% end %>
12

  
8 13
<p><label for="issue_status_is_closed"><%=l(:field_is_closed)%></label>
9 14
<%= check_box 'issue_status', 'is_closed' %></p>
10 15

  
app/views/issue_statuses/list.rhtml
1 1
<div class="contextual">
2 2
<%= link_to l(:label_issue_status_new), {:action => 'new'}, :class => 'icon icon-add' %>
3
<%= link_to(l(:label_update_issue_done_ratios), {:action => 'update_issue_done_ratio'}, :class => 'icon icon-multiple', :method => 'post', :confirm => l(:text_are_you_sure)) if Setting.issue_status_for_done_ratio? %>
3 4
</div>
4 5

  
5 6
<h2><%=l(:label_issue_status_plural)%></h2>
......
7 8
<table class="list">
8 9
  <thead><tr>
9 10
  <th><%=l(:field_status)%></th>
11
  <% if Setting.issue_status_for_done_ratio? %>
12
  <th><%=l(:field_done_ratio)%></th>
13
  <% end %>
10 14
  <th><%=l(:field_is_default)%></th>
11 15
  <th><%=l(:field_is_closed)%></th>
12 16
  <th><%=l(:button_sort)%></th>
......
16 20
<% for status in @issue_statuses %>
17 21
  <tr class="<%= cycle("odd", "even") %>">
18 22
  <td><%= link_to status.name, :action => 'edit', :id => status %></td>
23
  <% if Setting.issue_status_for_done_ratio? %>
24
  <td align="center"><%= h status.default_done_ratio %></td>
25
  <% end %>
19 26
  <td align="center"><%= image_tag 'true.png' if status.is_default? %></td>
20 27
  <td align="center"><%= image_tag 'true.png' if status.is_closed? %></td>
21 28
  <td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}) %></td>
app/views/issues/_form.rhtml
41 41
<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
42 42
<p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p>
43 43
<p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p>
44
<% unless Setting.issue_status_for_done_ratio? %>
44 45
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
46
<% end %>
45 47
</div>
46 48

  
47 49
<div style="clear:both;"> </div>
app/views/issues/_form_update.rhtml
4 4
<p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p>
5 5
</div>
6 6
<div class="splitcontentright">
7
<% unless Setting.issue_status_for_done_ratio? %>
7 8
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
9
<% end %>
8 10
<% unless @issue.assignable_versions.empty? %>
9 11
<p><%= f.select :fixed_version_id, (@issue.assignable_versions.collect {|v| [v.name, v.id]}), :include_blank => true %></p>
10 12
<% end %>
app/views/issues/bulk_edit.rhtml
35 35
<%= text_field_tag 'start_date', '', :size => 10 %><%= calendar_for('start_date') %></label>
36 36
<label><%= l(:field_due_date) %>: 
37 37
<%= text_field_tag 'due_date', '', :size => 10 %><%= calendar_for('due_date') %></label>
38
<% unless Setting.issue_status_for_done_ratio? %>
38 39
<label><%= l(:field_done_ratio) %>: 
39 40
<%= select_tag 'done_ratio', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></label>
41
<% end %>
40 42
</p>
41 43

  
42 44
<% @custom_fields.each do |custom_field| %>
app/views/issues/context_menu.rhtml
66 66
		</ul>
67 67
	</li>
68 68
	<% end -%>
69
  <% unless Setting.issue_status_for_done_ratio? %>
69 70
	<li class="folder">
70 71
		<a href="#" class="submenu"><%= l(:field_done_ratio) %></a>
71 72
		<ul>
......
75 76
		<% end -%>
76 77
		</ul>
77 78
	</li>
78
	
79
  <% end %>
79 80
<% if !@issue.nil? %>
80 81
	<li><%= context_menu_link l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue},
81 82
	        :class => 'icon-copy', :disabled => !@can[:copy] %></li>
app/views/settings/_issues.rhtml
11 11
<%= check_box_tag 'settings[display_subprojects_issues]', 1, Setting.display_subprojects_issues? %>
12 12
</p>
13 13

  
14
<p><label><%= l(:setting_use_issue_status_for_done_ratio) %></label>
15
<%= hidden_field_tag 'settings[issue_status_for_done_ratio]', 0 %>
16
<%= check_box_tag 'settings[issue_status_for_done_ratio]', 1, Setting.issue_status_for_done_ratio? %>
17
</p>
18

  
14 19
<p><label><%= l(:setting_issues_export_limit) %></label>
15 20
<%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p>
16 21
</div>
config/locales/bg.yml
835 835
  button_move_and_follow: Move and follow
836 836
  setting_default_projects_modules: Default enabled modules for new projects
837 837
  setting_gravatar_default: Default Gravatar image
838
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
839
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
840
  notice_issue_done_ratios_updated: Issue done ratios updated.
841
  label_update_issue_done_ratios: Update issue done ratios
config/locales/bs.yml
859 859
  button_move_and_follow: Move and follow
860 860
  setting_default_projects_modules: Default enabled modules for new projects
861 861
  setting_gravatar_default: Default Gravatar image
862
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
863
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
864
  notice_issue_done_ratios_updated: Issue done ratios updated.
865
  label_update_issue_done_ratios: Update issue done ratios
config/locales/ca.yml
838 838
  button_move_and_follow: Move and follow
839 839
  setting_default_projects_modules: Default enabled modules for new projects
840 840
  setting_gravatar_default: Default Gravatar image
841
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
842
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
843
  notice_issue_done_ratios_updated: Issue done ratios updated.
844
  label_update_issue_done_ratios: Update issue done ratios
config/locales/cs.yml
841 841
  button_move_and_follow: Move and follow
842 842
  setting_default_projects_modules: Default enabled modules for new projects
843 843
  setting_gravatar_default: Default Gravatar image
844
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
845
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
846
  notice_issue_done_ratios_updated: Issue done ratios updated.
847
  label_update_issue_done_ratios: Update issue done ratios
config/locales/da.yml
861 861
  button_move_and_follow: Move and follow
862 862
  setting_default_projects_modules: Default enabled modules for new projects
863 863
  setting_gravatar_default: Default Gravatar image
864
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
865
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
866
  notice_issue_done_ratios_updated: Issue done ratios updated.
867
  label_update_issue_done_ratios: Update issue done ratios
config/locales/de.yml
861 861
  button_move_and_follow: Move and follow
862 862
  setting_default_projects_modules: Default enabled modules for new projects
863 863
  setting_gravatar_default: Default Gravatar image
864
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
865
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
866
  notice_issue_done_ratios_updated: Issue done ratios updated.
867
  label_update_issue_done_ratios: Update issue done ratios
config/locales/el.yml
841 841
  button_move_and_follow: Move and follow
842 842
  setting_default_projects_modules: Default enabled modules for new projects
843 843
  setting_gravatar_default: Default Gravatar image
844
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
845
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
846
  notice_issue_done_ratios_updated: Issue done ratios updated.
847
  label_update_issue_done_ratios: Update issue done ratios
config/locales/en.yml
147 147
  notice_account_pending: "Your account was created and is now pending administrator approval."
148 148
  notice_default_data_loaded: Default configuration successfully loaded.
149 149
  notice_unable_delete_version: Unable to delete version.
150
  notice_issue_done_ratios_updated: Issue done ratios updated.
150 151
  
151 152
  error_can_t_load_default_data: "Default configuration could not be loaded: {{value}}"
152 153
  error_scm_not_found: "The entry or revision was not found in the repository."
......
156 157
  error_no_tracker_in_project: 'No tracker is associated to this project. Please check the Project settings.'
157 158
  error_no_default_issue_status: 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
158 159
  error_can_not_reopen_issue_on_closed_version: 'An issue assigned to a closed version can not be reopened'
159
  
160
  error_issue_done_ratios_not_updated: "Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'"
161

  
160 162
  warning_attachments_not_saved: "{{count}} file(s) could not be saved."
161 163
  
162 164
  mail_subject_lost_password: "Your {{value}} password"
......
307 309
  setting_sequential_project_identifiers: Generate sequential project identifiers
308 310
  setting_gravatar_enabled: Use Gravatar user icons
309 311
  setting_gravatar_default: Default Gravatar image
312
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
310 313
  setting_diff_max_lines_displayed: Max number of diff lines displayed
311 314
  setting_file_max_size_displayed: Max size of text files displayed inline
312 315
  setting_repository_log_display_limit: Maximum number of revisions displayed on file log
......
709 712
  label_group_plural: Groups
710 713
  label_group_new: New group
711 714
  label_time_entry_plural: Spent time
715
  label_update_issue_done_ratios: Update issue done ratios
712 716
  
713 717
  button_login: Login
714 718
  button_submit: Submit
config/locales/es.yml
882 882
  button_move_and_follow: Move and follow
883 883
  setting_default_projects_modules: Default enabled modules for new projects
884 884
  setting_gravatar_default: Default Gravatar image
885
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
886
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
887
  notice_issue_done_ratios_updated: Issue done ratios updated.
888
  label_update_issue_done_ratios: Update issue done ratios
config/locales/fi.yml
871 871
  button_move_and_follow: Move and follow
872 872
  setting_default_projects_modules: Default enabled modules for new projects
873 873
  setting_gravatar_default: Default Gravatar image
874
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
875
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
876
  notice_issue_done_ratios_updated: Issue done ratios updated.
877
  label_update_issue_done_ratios: Update issue done ratios
config/locales/fr.yml
864 864
  field_active: Actif
865 865
  enumeration_system_activity: Activité système
866 866
  setting_gravatar_default: Default Gravatar image
867
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
868
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
869
  notice_issue_done_ratios_updated: Issue done ratios updated.
870
  label_update_issue_done_ratios: Update issue done ratios
config/locales/gl.yml
861 861
  button_move_and_follow: Move and follow
862 862
  setting_default_projects_modules: Default enabled modules for new projects
863 863
  setting_gravatar_default: Default Gravatar image
864
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
865
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
866
  notice_issue_done_ratios_updated: Issue done ratios updated.
867
  label_update_issue_done_ratios: Update issue done ratios
config/locales/he.yml
845 845
  button_move_and_follow: Move and follow
846 846
  setting_default_projects_modules: Default enabled modules for new projects
847 847
  setting_gravatar_default: Default Gravatar image
848
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
849
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
850
  notice_issue_done_ratios_updated: Issue done ratios updated.
851
  label_update_issue_done_ratios: Update issue done ratios
config/locales/hu.yml
866 866
  button_move_and_follow: Move and follow
867 867
  setting_default_projects_modules: Default enabled modules for new projects
868 868
  setting_gravatar_default: Default Gravatar image
869
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
870
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
871
  notice_issue_done_ratios_updated: Issue done ratios updated.
872
  label_update_issue_done_ratios: Update issue done ratios
config/locales/it.yml
848 848
  button_move_and_follow: Move and follow
849 849
  setting_default_projects_modules: Default enabled modules for new projects
850 850
  setting_gravatar_default: Default Gravatar image
851
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
852
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
853
  notice_issue_done_ratios_updated: Issue done ratios updated.
854
  label_update_issue_done_ratios: Update issue done ratios
config/locales/ja.yml
870 870
  button_move_and_follow: Move and follow
871 871
  setting_default_projects_modules: Default enabled modules for new projects
872 872
  setting_gravatar_default: Default Gravatar image
873
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
874
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
875
  notice_issue_done_ratios_updated: Issue done ratios updated.
876
  label_update_issue_done_ratios: Update issue done ratios
config/locales/ko.yml
901 901
  button_move_and_follow: Move and follow
902 902
  setting_default_projects_modules: Default enabled modules for new projects
903 903
  setting_gravatar_default: Default Gravatar image
904
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
905
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
906
  notice_issue_done_ratios_updated: Issue done ratios updated.
907
  label_update_issue_done_ratios: Update issue done ratios
config/locales/lt.yml
871 871
  button_move_and_follow: Move and follow
872 872
  setting_default_projects_modules: Default enabled modules for new projects
873 873
  setting_gravatar_default: Default Gravatar image
874
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
875
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
876
  notice_issue_done_ratios_updated: Issue done ratios updated.
877
  label_update_issue_done_ratios: Update issue done ratios
config/locales/nl.yml
823 823
  button_move_and_follow: Move and follow
824 824
  setting_default_projects_modules: Default enabled modules for new projects
825 825
  setting_gravatar_default: Default Gravatar image
826
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
827
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
828
  notice_issue_done_ratios_updated: Issue done ratios updated.
829
  label_update_issue_done_ratios: Update issue done ratios
config/locales/no.yml
836 836
  button_move_and_follow: Move and follow
837 837
  setting_default_projects_modules: Default enabled modules for new projects
838 838
  setting_gravatar_default: Default Gravatar image
839
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
840
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
841
  notice_issue_done_ratios_updated: Issue done ratios updated.
842
  label_update_issue_done_ratios: Update issue done ratios
config/locales/pl.yml
864 864
  button_move_and_follow: Move and follow
865 865
  setting_default_projects_modules: Default enabled modules for new projects
866 866
  setting_gravatar_default: Default Gravatar image
867
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
868
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
869
  notice_issue_done_ratios_updated: Issue done ratios updated.
870
  label_update_issue_done_ratios: Update issue done ratios
config/locales/pt-BR.yml
867 867
  button_move_and_follow: Mover e seguir
868 868
  setting_default_projects_modules: Módulos habilitados por padrão para novos projetos
869 869
  setting_gravatar_default: Imagem Gravatar padrão
870
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
871
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
872
  notice_issue_done_ratios_updated: Issue done ratios updated.
873
  label_update_issue_done_ratios: Update issue done ratios
config/locales/pt.yml
853 853
  button_move_and_follow: Move and follow
854 854
  setting_default_projects_modules: Default enabled modules for new projects
855 855
  setting_gravatar_default: Default Gravatar image
856
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
857
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
858
  notice_issue_done_ratios_updated: Issue done ratios updated.
859
  label_update_issue_done_ratios: Update issue done ratios
config/locales/ro.yml
838 838
  button_move_and_follow: Move and follow
839 839
  setting_default_projects_modules: Default enabled modules for new projects
840 840
  setting_gravatar_default: Default Gravatar image
841
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
842
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
843
  notice_issue_done_ratios_updated: Issue done ratios updated.
844
  label_update_issue_done_ratios: Update issue done ratios
config/locales/ru.yml
949 949
  button_move_and_follow: Переместить и перейти
950 950
  setting_default_projects_modules: Включенные по умолчанию модули для новых проектов
951 951
  setting_gravatar_default: Изображение Gravatar по умолчанию
952
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
953
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
954
  notice_issue_done_ratios_updated: Issue done ratios updated.
955
  label_update_issue_done_ratios: Update issue done ratios
config/locales/sk.yml
840 840
  button_move_and_follow: Move and follow
841 841
  setting_default_projects_modules: Default enabled modules for new projects
842 842
  setting_gravatar_default: Default Gravatar image
843
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
844
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
845
  notice_issue_done_ratios_updated: Issue done ratios updated.
846
  label_update_issue_done_ratios: Update issue done ratios
config/locales/sl.yml
837 837
  button_move_and_follow: Move and follow
838 838
  setting_default_projects_modules: Default enabled modules for new projects
839 839
  setting_gravatar_default: Default Gravatar image
840
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
841
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
842
  notice_issue_done_ratios_updated: Issue done ratios updated.
843
  label_update_issue_done_ratios: Update issue done ratios
config/locales/sr.yml
856 856
  button_move_and_follow: Move and follow
857 857
  setting_default_projects_modules: Default enabled modules for new projects
858 858
  setting_gravatar_default: Default Gravatar image
859
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
860
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
861
  notice_issue_done_ratios_updated: Issue done ratios updated.
862
  label_update_issue_done_ratios: Update issue done ratios
config/locales/sv.yml
889 889
  button_move_and_follow: Move and follow
890 890
  setting_default_projects_modules: Default enabled modules for new projects
891 891
  setting_gravatar_default: Default Gravatar image
892
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
893
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
894
  notice_issue_done_ratios_updated: Issue done ratios updated.
895
  label_update_issue_done_ratios: Update issue done ratios
config/locales/th.yml
838 838
  button_move_and_follow: Move and follow
839 839
  setting_default_projects_modules: Default enabled modules for new projects
840 840
  setting_gravatar_default: Default Gravatar image
841
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
842
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
843
  notice_issue_done_ratios_updated: Issue done ratios updated.
844
  label_update_issue_done_ratios: Update issue done ratios
config/locales/tr.yml
868 868
  button_move_and_follow: Move and follow
869 869
  setting_default_projects_modules: Default enabled modules for new projects
870 870
  setting_gravatar_default: Default Gravatar image
871
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
872
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
873
  notice_issue_done_ratios_updated: Issue done ratios updated.
874
  label_update_issue_done_ratios: Update issue done ratios
config/locales/uk.yml
837 837
  button_move_and_follow: Move and follow
838 838
  setting_default_projects_modules: Default enabled modules for new projects
839 839
  setting_gravatar_default: Default Gravatar image
840
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
841
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
842
  notice_issue_done_ratios_updated: Issue done ratios updated.
843
  label_update_issue_done_ratios: Update issue done ratios
config/locales/vi.yml
900 900
  button_move_and_follow: Move and follow
901 901
  setting_default_projects_modules: Default enabled modules for new projects
902 902
  setting_gravatar_default: Default Gravatar image
903
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
904
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
905
  notice_issue_done_ratios_updated: Issue done ratios updated.
906
  label_update_issue_done_ratios: Update issue done ratios
config/locales/zh-TW.yml
932 932
  enumeration_doc_categories: 文件分類
933 933
  enumeration_activities: 活動 (時間追蹤)
934 934
  enumeration_system_activity: 系統活動
935
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
936
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
937
  notice_issue_done_ratios_updated: Issue done ratios updated.
938
  label_update_issue_done_ratios: Update issue done ratios
config/locales/zh.yml
865 865
  button_move_and_follow: Move and follow
866 866
  setting_default_projects_modules: Default enabled modules for new projects
867 867
  setting_gravatar_default: Default Gravatar image
868
  error_issue_done_ratios_not_updated: Issue done ratios not updated.  Please confirm you enabled 'Use issue status for  done ratio'
869
  setting_use_issue_status_for_done_ratio: Use issue status for done ratio
870
  notice_issue_done_ratios_updated: Issue done ratios updated.
871
  label_update_issue_done_ratios: Update issue done ratios
config/settings.yml
129 129
  - updated_on
130 130
display_subprojects_issues:
131 131
  default: 1
132
issue_status_for_done_ratio:
133
  default: 0
132 134
default_projects_public:
133 135
  default: 1
134 136
default_projects_modules:
db/migrate/20091123212029_add_default_done_ratio_to_issue_status.rb
1
class AddDefaultDoneRatioToIssueStatus < ActiveRecord::Migration
2
  def self.up
3
    add_column :issue_statuses, :default_done_ratio, :integer
4
  end
5

  
6
  def self.down
7
    remove_column :issue_statuses, :default_one_ratio
8
  end
9
end
public/stylesheets/application.css
698 698
.icon-move { background-image: url(../images/move.png); }
699 699
.icon-save { background-image: url(../images/save.png); }
700 700
.icon-cancel { background-image: url(../images/cancel.png); }
701
.icon-multiple { background-image: url(../images/table_multiple.png); }
701 702
.icon-folder { background-image: url(../images/folder.png); }
702 703
.open .icon-folder { background-image: url(../images/folder_open.png); }
703 704
.icon-package { background-image: url(../images/package.png); }
test/functional/issue_statuses_controller_test.rb
70 70
    assert_redirected_to 'issue_statuses/list'
71 71
    assert_not_nil IssueStatus.find_by_id(1)
72 72
  end
73

  
74
  context "on POST to :update_issue_done_ratio" do
75
    context "with Setting.issue_status_for_done_ratio off" do
76
      setup do
77
        Setting.issue_status_for_done_ratio = 0
78
        post :update_issue_done_ratio
79
      end
80

  
81
      should_set_the_flash_to /not updated/
82
      should_redirect_to('the list') { '/issue_statuses/list' }
83
    end
84

  
85
    context "with Setting.issue_status_for_done_ratio on" do
86
      setup do
87
        Setting.issue_status_for_done_ratio = 1
88
        post :update_issue_done_ratio
89
      end
90

  
91
      should_set_the_flash_to /Issue done ratios updated/
92
      should_redirect_to('the list') { '/issue_statuses/list' }
93
    end
94
  end
95
  
73 96
end
test/unit/issue_status_test.rb
66 66
    status.reload
67 67
    assert status.is_default?
68 68
  end
69

  
70
  context "#update_done_ratios" do
71
    setup do
72
      @issue = Issue.find(1)
73
      @issue_status = IssueStatus.find(1)
74
      @issue_status.update_attribute(:default_done_ratio, 50)
75
    end
76
    
77
    context "with Setting.issue_status_for_done_ratio off" do
78
      setup do
79
        Setting.issue_status_for_done_ratio = 0
80
      end
81
      
82
      should "change nothing" do
83
        assert_equal 0, Issue.count(:conditions => {:done_ratio => 50})
84
      end
85
    end
86

  
87
    context "with Setting.issue_status_for_done_ratio on" do
88
      setup do
89
        Setting.issue_status_for_done_ratio = 1
90
      end
91
      
92
      should "update all of the issue's done_ratios to match their Issue Status" do
93
        IssueStatus.update_issue_done_ratios
94
        
95
        issues = Issue.find([1,3,4,5,6,7,9,10])
96
        issues.each do |issue|
97
          assert_equal @issue_status, issue.status
98
          assert_equal 50, issue.read_attribute(:done_ratio)
99
        end
100
      end
101
    end
102
  end
69 103
end
test/unit/issue_test.rb
400 400
    end
401 401
    assert ActionMailer::Base.deliveries.empty?
402 402
  end
403

  
404
  context "#done_ratio" do
405
    setup do
406
      @issue = Issue.find(1)
407
      @issue_status = IssueStatus.find(1)
408
      @issue_status.update_attribute(:default_done_ratio, 50)
409
    end
410
    
411
    context "with Setting.issue_status_for_done_ratio off" do
412
      setup do
413
        Setting.issue_status_for_done_ratio = 0
414
      end
415
      
416
      should "read the issue's field" do
417
        assert_equal 0, @issue.done_ratio
418
      end
419
    end
420

  
421
    context "with Setting.issue_status_for_done_ratio on" do
422
      setup do
423
        Setting.issue_status_for_done_ratio = 1
424
      end
425
      
426
      should "read the Issue Status's default done ratio" do
427
        assert_equal 50, @issue.done_ratio
428
      end
429
    end
430
  end
431

  
432
  context "#update_done_ratio_from_issue_status" do
433
    setup do
434
      @issue = Issue.find(1)
435
      @issue_status = IssueStatus.find(1)
436
      @issue_status.update_attribute(:default_done_ratio, 50)
437
    end
438
    
439
    context "with Setting.issue_status_for_done_ratio off" do
440
      setup do
441
        Setting.issue_status_for_done_ratio = 0
442
      end
443
      
444
      should "not change the issue" do
445
        @issue.update_done_ratio_from_issue_status
446

  
447
        assert_equal 0, @issue.done_ratio
448
      end
449
    end
450

  
451
    context "with Setting.issue_status_for_done_ratio on" do
452
      setup do
453
        Setting.issue_status_for_done_ratio = 1
454
      end
455
      
456
      should "not change the issue's done ratio" do
457
        @issue.update_done_ratio_from_issue_status
458

  
459
        assert_equal 50, @issue.done_ratio
460
      end
461
    end
462
  end
403 463
end
(1-1/4)