Project

General

Profile

Patch #7443 » found-version-1.1.0.patch

bugfix2 - Brian Lindahl, 2011-02-11 01:17

View differences:

redmine-1.1.0-found-version/app/controllers/issue_moves_controller.rb 2011-02-10 17:13:06.175072400 -0700
@target_project ||= @project
@trackers = @target_project.trackers
@available_statuses = Workflow.available_statuses(@project)
@found_versions = @target_project.shared_versions.locked
@notes = params[:notes]
@notes ||= ''
end
def extract_changed_attributes_for_move(params)
changed_attributes = {}
[:assigned_to_id, :status_id, :start_date, :due_date, :priority_id].each do |valid_attribute|
[:assigned_to_id, :status_id, :found_version_id, :start_date, :due_date, :priority_id].each do |valid_attribute|
unless params[valid_attribute].blank?
changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute])
end
redmine-1.1.0-found-version/app/controllers/issues_controller.rb 2011-02-10 17:13:06.175072400 -0700
@issue_count = @query.issue_count
@issue_pages = Paginator.new self, @issue_count, @limit, params['page']
@offset ||= @issue_pages.current.offset
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :found_version, :fixed_version],
:order => sort_clause,
:offset => @offset,
:limit => @limit)
redmine-1.1.0-found-version/app/controllers/reports_controller.rb 2011-02-10 17:13:06.190697600 -0700
@subprojects = @project.descendants.visible
@issues_by_tracker = Issue.by_tracker(@project)
@issues_by_version = Issue.by_version(@project)
@issues_by_found_version = Issue.by_found_version(@project)
@issues_by_fixed_version = Issue.by_fixed_version(@project)
@issues_by_priority = Issue.by_priority(@project)
@issues_by_category = Issue.by_category(@project)
@issues_by_assigned_to = Issue.by_assigned_to(@project)
......
@rows = @project.trackers
@data = Issue.by_tracker(@project)
@report_title = l(:field_tracker)
when "version"
when "found_version"
@field = "found_version_id"
@rows = @project.shared_versions.sort
@data = Issue.by_found_version(@project)
@report_title = l(:field_found_version)
when "fixed_version"
@field = "fixed_version_id"
@rows = @project.shared_versions.sort
@data = Issue.by_version(@project)
@report_title = l(:field_version)
@data = Issue.by_fixed_version(@project)
@report_title = l(:field_fixed_version)
when "priority"
@field = "priority_id"
@rows = IssuePriority.all
redmine-1.1.0-found-version/app/controllers/versions_controller.rb 2011-02-10 17:13:35.144193200 -0700
end
def destroy
if @version.fixed_issues.empty?
if @version.found_issues.empty? && @version.fixed_issues.empty?
@version.destroy
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
else
redmine-1.1.0-found-version/app/helpers/issues_helper.rb 2011-02-10 17:13:06.206322800 -0700
value = format_date(detail.value.to_date) if detail.value
old_value = format_date(detail.old_value.to_date) if detail.old_value
when ['project_id', 'status_id', 'tracker_id', 'assigned_to_id', 'priority_id', 'category_id', 'fixed_version_id'].include?(detail.prop_key)
when ['project_id', 'status_id', 'tracker_id', 'assigned_to_id', 'priority_id', 'category_id', 'found_version_id', 'fixed_version_id'].include?(detail.prop_key)
value = find_name_by_reflection(field, detail.value)
old_value = find_name_by_reflection(field, detail.old_value)
......
l(:field_subject),
l(:field_assigned_to),
l(:field_category),
l(:field_found_version),
l(:field_fixed_version),
l(:field_author),
l(:field_start_date),
......
issue.subject,
issue.assigned_to,
issue.category,
issue.found_version,
issue.fixed_version,
issue.author.name,
format_date(issue.start_date),
redmine-1.1.0-found-version/app/models/issue.rb 2011-02-10 17:13:06.221948000 -0700
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
belongs_to :found_version, :class_name => 'Version', :foreign_key => 'found_version_id'
belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id'
belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
......
attr_reader :current_journal
validates_presence_of :subject, :priority, :project, :tracker, :author, :status
validates_presence_of :found_version, :unless => Proc.new { |issue| issue.found_assignable_versions.empty? }
validates_length_of :subject, :maximum => 255
validates_inclusion_of :done_ratio, :in => 0..100
......
# reassign to the category with same name if any
new_category = issue.category.nil? ? nil : new_project.issue_categories.find_by_name(issue.category.name)
issue.category = new_category
# Keep the fixed_version if it's still valid in the new_project
# Keep the found version if it's still valid in the new_project
unless new_project.shared_versions.include?(issue.found_version)
issue.found_version = nil
end
# Keep the fixed version if it's still valid in the new_project
unless new_project.shared_versions.include?(issue.fixed_version)
issue.fixed_version = nil
end
......
'category_id',
'assigned_to_id',
'priority_id',
'found_version_id',
'fixed_version_id',
'subject',
'description',
......
errors.add :start_date, :invalid
end
if found_version
if !found_assignable_versions.include?(found_version)
errors.add :found_version_id, :inclusion
end
end
if fixed_version
if !assignable_versions.include?(fixed_version)
if !fixed_assignable_versions.include?(fixed_version)
errors.add :fixed_version_id, :inclusion
elsif reopened? && fixed_version.closed?
errors.add_to_base I18n.t(:error_can_not_reopen_issue_on_closed_version)
......
users.uniq.sort
end
# Versions that the issue can be assigned to
def assignable_versions
@assignable_versions ||= (project.shared_versions.open + [Version.find_by_id(fixed_version_id_was)]).compact.uniq.sort
# Versions that the issue can be assigned as fixed to
def found_assignable_versions
@found_assignable_versions ||= project.shared_versions.locked
end
# Versions that the issue can be assigned as fixed to
def fixed_assignable_versions
@fixed_assignable_versions ||= project.shared_versions.open
end
# Returns true if this issue is blocked by another issue that is still open
......
# Unassigns issues from +version+ if it's no longer shared with issue's project
def self.update_versions_from_sharing_change(version)
# Update issues assigned to the version
update_versions(["#{Issue.table_name}.found_version_id = ?", version.id])
update_versions(["#{Issue.table_name}.fixed_version_id = ?", version.id])
end
......
:joins => Tracker.table_name)
end
def self.by_version(project)
def self.by_found_version(project)
count_and_group_by(:project => project,
:field => 'found_version_id',
:joins => Version.table_name)
end
def self.by_fixed_version(project)
count_and_group_by(:project => project,
:field => 'fixed_version_id',
:joins => Version.table_name)
......
issue.save
end
end
# Only need to update issues with a found_version from
# a different project and that is not systemwide shared
Issue.all(:conditions => merge_conditions("#{Issue.table_name}.found_version_id IS NOT NULL" +
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
" AND #{Version.table_name}.sharing <> 'system'",
conditions),
:include => [:project, :found_version]
).each do |issue|
next if issue.project.nil? || issue.found_version.nil?
unless issue.project.shared_versions.include?(issue.found_version)
issue.init_journal(User.current)
issue.found_version = nil
issue.save
end
end
end
# Callback on attachment deletion
redmine-1.1.0-found-version/app/models/mail_handler.rb 2011-02-10 17:13:06.221948000 -0700
'priority_id' => (k = get_keyword(:priority)) && IssuePriority.find_by_name(k).try(:id),
'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.find_by_name(k).try(:id),
'assigned_to_id' => assigned_to.try(:id),
'found_version_id' => (k = get_keyword(:found_version, :override => true)) && issue.project.shared_versions.find_by_name(k).try(:id),
'fixed_version_id' => (k = get_keyword(:fixed_version, :override => true)) && issue.project.shared_versions.find_by_name(k).try(:id),
'start_date' => get_keyword(:start_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
'due_date' => get_keyword(:due_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
redmine-1.1.0-found-version/app/models/project.rb 2011-02-10 17:13:06.237573200 -0700
new_issue = Issue.new
new_issue.copy_from(issue)
new_issue.project = self
# Reassign fixed_versions by name, since names are unique per
# Reassign versions by name, since names are unique per
# project and the versions for self are not yet saved
if issue.found_version
new_issue.found_version = self.versions.select {|v| v.name == issue.found_version.name}.first
end
if issue.fixed_version
new_issue.fixed_version = self.versions.select {|v| v.name == issue.fixed_version.name}.first
end
redmine-1.1.0-found-version/app/models/query.rb 2011-02-10 17:13:06.253198400 -0700
QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname", "#{User.table_name}.id"], :groupable => true),
QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
QueryColumn.new(:found_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true),
QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true),
QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
......
@available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
"tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } },
"priority_id" => { :type => :list, :order => 3, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] } },
"subject" => { :type => :text, :order => 8 },
"created_on" => { :type => :date_past, :order => 9 },
"updated_on" => { :type => :date_past, :order => 10 },
"start_date" => { :type => :date, :order => 11 },
"due_date" => { :type => :date, :order => 12 },
"estimated_hours" => { :type => :integer, :order => 13 },
"done_ratio" => { :type => :integer, :order => 14 }}
"subject" => { :type => :text, :order => 9 },
"created_on" => { :type => :date_past, :order => 10 },
"updated_on" => { :type => :date_past, :order => 11 },
"start_date" => { :type => :date, :order => 12 },
"due_date" => { :type => :date, :order => 13 },
"estimated_hours" => { :type => :integer, :order => 14 },
"done_ratio" => { :type => :integer, :order => 15 }}
user_values = []
user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
......
@available_filters["assigned_to_role"] = { :type => :list_optional, :order => 7, :values => role_values } unless role_values.empty?
if User.current.logged?
@available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] }
@available_filters["watcher_id"] = { :type => :list, :order => 16, :values => [["<< #{l(:label_me)} >>", "me"]] }
end
if project
......
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
end
unless @project.shared_versions.empty?
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
@available_filters["found_version_id"] = { :type => :list_optional, :order => 7, :values => @project.shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 8, :values => @project.shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
end
unless @project.descendants.active.empty?
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.descendants.visible.collect{|s| [s.name, s.id.to_s] } }
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 14, :values => @project.descendants.visible.collect{|s| [s.name, s.id.to_s] } }
end
add_custom_fields_filters(@project.all_issue_custom_fields)
else
# global filters for cross project issue list
system_shared_versions = Version.visible.find_all_by_sharing('system')
unless system_shared_versions.empty?
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => system_shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
@available_filters["found_version_id"] = { :type => :list_optional, :order => 7, :values => system_shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 8, :values => system_shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
end
add_custom_fields_filters(IssueCustomField.find(:all, :conditions => {:is_filter => true, :is_for_all => true}))
end
redmine-1.1.0-found-version/app/models/version.rb 2011-02-10 17:13:06.268823600 -0700
class Version < ActiveRecord::Base
after_update :update_issues_from_sharing_change
belongs_to :project
has_many :found_issues, :class_name => 'Issue', :foreign_key => 'found_version_id', :dependent => :nullify
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id', :dependent => :nullify
acts_as_customizable
acts_as_attachable :view_permission => :view_files,
......
validates_inclusion_of :sharing, :in => VERSION_SHARINGS
named_scope :open, :conditions => {:status => 'open'}
named_scope :locked, :conditions => {:status => 'locked'}
named_scope :closed, :conditions => {:status => 'closed'}
named_scope :visible, lambda {|*args| { :include => :project,
:conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } }
redmine-1.1.0-found-version/app/views/issue_moves/new.rhtml 2011-02-10 17:13:06.284448800 -0700
<%= select_tag('status_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@available_statuses, :id, :name)) %>
</p>
<% if !@found_versions.empty? %>
<p>
<label for="new_found_version_id"><%=l(:field_found_version) %></label>
<%= select_tag('new_found_version_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@found_versions, :id, :name)) %>
</p>
<% end %>
<p>
<label><%= l(:field_priority) %></label>
<%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %>
redmine-1.1.0-found-version/app/views/issues/_attributes.rhtml 2011-02-10 17:13:06.284448800 -0700
:title => l(:label_issue_category_new),
:tabindex => 199) if authorize_for('issue_categories', 'new') %></p>
<% end %>
<% unless @issue.assignable_versions.empty? %>
<p><%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true %>
<% unless @issue.found_assignable_versions.empty? %>
<p><%= f.select :found_version_id, version_options_for_select(@issue.found_assignable_versions, @issue.found_version), :include_blank => true, :required => true %></p>
<% end %>
<% unless @issue.fixed_assignable_versions.empty? %>
<p><%= f.select :fixed_version_id, version_options_for_select(@issue.fixed_assignable_versions, @issue.fixed_version), :include_blank => true %>
<%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'),
l(:label_version_new),
'version[name]',
redmine-1.1.0-found-version/app/views/issues/_form_update.rhtml 2011-02-10 17:13:06.300074000 -0700
<% if Issue.use_field_for_done_ratio? %>
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
<% end %>
<% unless @issue.assignable_versions.empty? %>
<p><%= f.select :fixed_version_id, (@issue.assignable_versions.collect {|v| [v.name, v.id]}), :include_blank => true %></p>
<% unless @issue.fixed_assignable_versions.empty? %>
<p><%= f.select :fixed_version_id, (@issue.fixed_assignable_versions.collect {|v| [v.name, v.id]}), :include_blank => true %></p>
<% end %>
</div>
</div>
redmine-1.1.0-found-version/app/views/issues/bulk_edit.rhtml 2011-02-10 17:13:06.315699200 -0700
<% #TODO: allow editing versions when multiple projects %>
<% if @project %>
<p>
<label><%= l(:field_found_version) %></label>
<%= select_tag('issue[found_version_id]', content_tag('option', l(:label_no_change_option), :value => '') +
content_tag('option', l(:label_none), :value => 'none') +
version_options_for_select(@project.shared_versions.locked)) %>
</p>
<p>
<label><%= l(:field_fixed_version) %></label>
<%= select_tag('issue[fixed_version_id]', content_tag('option', l(:label_no_change_option), :value => '') +
content_tag('option', l(:label_none), :value => 'none') +
version_options_for_select(@project.shared_versions.open.sort)) %>
version_options_for_select(@project.shared_versions.open)) %>
</p>
<% end %>
redmine-1.1.0-found-version/app/views/issues/index.api.rsb 2011-02-10 17:13:06.315699200 -0700
api.author(:id => issue.author_id, :name => issue.author.name) unless issue.author.nil?
api.assigned_to(:id => issue.assigned_to_id, :name => issue.assigned_to.name) unless issue.assigned_to.nil?
api.category(:id => issue.category_id, :name => issue.category.name) unless issue.category.nil?
api.found_version(:id => issue.found_version_id, :name => issue.found_version.name) unless issue.found_version.nil?
api.fixed_version(:id => issue.fixed_version_id, :name => issue.fixed_version.name) unless issue.fixed_version.nil?
api.parent(:id => issue.parent_id) unless issue.parent.nil?
redmine-1.1.0-found-version/app/views/issues/show.api.rsb 2011-02-10 17:13:06.331324400 -0700
api.author(:id => @issue.author_id, :name => @issue.author.name) unless @issue.author.nil?
api.assigned_to(:id => @issue.assigned_to_id, :name => @issue.assigned_to.name) unless @issue.assigned_to.nil?
api.category(:id => @issue.category_id, :name => @issue.category.name) unless @issue.category.nil?
api.found_version(:id => @issue.found_version_id, :name => @issue.found_version.name) unless @issue.found_version.nil?
api.fixed_version(:id => @issue.fixed_version_id, :name => @issue.fixed_version.name) unless @issue.fixed_version.nil?
api.parent(:id => @issue.parent_id) unless @issue.parent.nil?
redmine-1.1.0-found-version/app/views/issues/show.rhtml 2011-02-10 17:13:06.346949600 -0700
<% end %>
</tr>
<tr>
<th class="fixed-version"><%=l(:field_fixed_version)%>:</th><td class="fixed-version"><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
<th class="found-version"><%=l(:field_found_version)%>:</th><td class="found-version"><%= @issue.found_version ? link_to_version(@issue.found_version) : "-" %></td>
<% if @issue.estimated_hours %>
<th class="estimated-hours"><%=l(:field_estimated_hours)%>:</th><td class="estimated-hours"><%= l_hours(@issue.estimated_hours) %></td>
<% end %>
</tr>
<tr>
<th class="fixed-version"><%=l(:field_fixed_version)%>:</th><td class="fixed-version"><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
</tr>
<%= render_custom_fields_rows(@issue) %>
<%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
</table>
redmine-1.1.0-found-version/app/views/mailer/_issue_text_html.rhtml 2011-02-10 17:13:06.346949600 -0700
<li><%=l(:field_priority)%>: <%=h issue.priority %></li>
<li><%=l(:field_assigned_to)%>: <%=h issue.assigned_to %></li>
<li><%=l(:field_category)%>: <%=h issue.category %></li>
<li><%=l(:field_found_version)%>: <%=h issue.found_version %></li>
<li><%=l(:field_fixed_version)%>: <%=h issue.fixed_version %></li>
<% issue.custom_values.each do |c| %>
<li><%=h c.custom_field.name %>: <%=h show_value(c) %></li>
redmine-1.1.0-found-version/app/views/mailer/_issue_text_plain.rhtml 2011-02-10 17:13:06.362574800 -0700
<%=l(:field_priority)%>: <%= issue.priority %>
<%=l(:field_assigned_to)%>: <%= issue.assigned_to %>
<%=l(:field_category)%>: <%= issue.category %>
<%=l(:field_found_version)%>: <%= issue.found_version %>
<%=l(:field_fixed_version)%>: <%= issue.fixed_version %>
<% issue.custom_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c) %>
<% end %>
redmine-1.1.0-found-version/app/views/reports/issue_report.rhtml 2011-02-10 17:13:06.362574800 -0700
</div>
<div class="splitcontentright">
<h3><%=l(:field_version)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'version' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_version, :field_name => "fixed_version_id", :rows => @versions } %>
<h3><%=l(:field_found_version)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'found_version' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_found_version, :field_name => "found_version_id", :rows => @versions } %>
<br />
<h3><%=l(:field_fixed_version)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'fixed_version' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_fixed_version, :field_name => "fixed_version_id", :rows => @versions } %>
<br />
<% if @project.children.any? %>
<h3><%=l(:field_subproject)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :action => 'issue_report_details', :detail => 'subproject' %></h3>
redmine-1.1.0-found-version/config/locales/en.yml 2011-02-10 17:13:06.378200000 -0700
field_due_date: Due date
field_assigned_to: Assignee
field_priority: Priority
field_found_version: Found in version
field_fixed_version: Target version
field_user: User
field_principal: Principal
redmine-1.1.0-found-version/db/migrate/20101114115360_add_found_version.rb 2011-02-10 17:13:06.393825200 -0700
class AddFoundInVersion < ActiveRecord::Migration
def self.up
add_column :issues, :found_version_id, :integer
add_index :issues, :found_version_id
end
def self.down
remove_index :issues, :found_version_id
remove_column :issues, :found_version_id
end
end
(7-7/15)