Feature #3007 » enumeration-sti.patch
| app/controllers/documents_controller.rb | ||
|---|---|---|
|
end
|
||
|
|
||
|
def edit
|
||
|
@categories = Enumeration.document_categories
|
||
|
@categories = DocumentCategory.all
|
||
|
if request.post? and @document.update_attributes(params[:document])
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
|
redirect_to :action => 'show', :id => @document
|
||
| app/controllers/enumerations_controller.rb | ||
|---|---|---|
|
end
|
||
|
def new
|
||
|
@enumeration = Enumeration.new(:opt => params[:opt])
|
||
|
@enumeration = Enumeration.new(:type => params[:type])
|
||
|
end
|
||
|
def create
|
||
|
@enumeration = Enumeration.new(params[:enumeration])
|
||
|
if @enumeration.save
|
||
|
flash[:notice] = l(:notice_successful_create)
|
||
|
redirect_to :action => 'list', :opt => @enumeration.opt
|
||
|
redirect_to :action => 'list', :type => @enumeration.type
|
||
|
else
|
||
|
render :action => 'new'
|
||
|
end
|
||
| ... | ... | |
|
@enumeration = Enumeration.find(params[:id])
|
||
|
if @enumeration.update_attributes(params[:enumeration])
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
|
redirect_to :action => 'list', :opt => @enumeration.opt
|
||
|
redirect_to :action => 'list', :type => @enumeration.type
|
||
|
else
|
||
|
render :action => 'edit'
|
||
|
end
|
||
| ... | ... | |
|
@enumeration.destroy
|
||
|
redirect_to :action => 'index'
|
||
|
elsif params[:reassign_to_id]
|
||
|
if reassign_to = Enumeration.find_by_opt_and_id(@enumeration.opt, params[:reassign_to_id])
|
||
|
if reassign_to = Enumeration.find_by_type_and_id(@enumeration.type, params[:reassign_to_id])
|
||
|
@enumeration.destroy(reassign_to)
|
||
|
redirect_to :action => 'index'
|
||
|
end
|
||
|
end
|
||
|
@enumerations = Enumeration.values(@enumeration.opt) - [@enumeration]
|
||
|
@enumerations = Enumeration.find(:all, :conditions => ['type = (?)', @enumeration.type]) - [@enumeration]
|
||
|
#rescue
|
||
|
# flash[:error] = 'Unable to delete enumeration'
|
||
|
# redirect_to :action => 'index'
|
||
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
|
||
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||
|
@priorities = Enumeration.priorities
|
||
|
@priorities = IssuePriority.all
|
||
|
@time_entry = TimeEntry.new
|
||
|
respond_to do |format|
|
||
|
format.html { render :template => 'issues/show.rhtml' }
|
||
| ... | ... | |
|
return
|
||
|
end
|
||
|
end
|
||
|
@priorities = Enumeration.priorities
|
||
|
@priorities = IssuePriority.all
|
||
|
render :layout => !request.xhr?
|
||
|
end
|
||
|
|
||
| ... | ... | |
|
|
||
|
def edit
|
||
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||
|
@priorities = Enumeration.priorities
|
||
|
@priorities = IssuePriority.all
|
||
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||
|
@time_entry = TimeEntry.new
|
||
|
|
||
| ... | ... | |
|
def bulk_edit
|
||
|
if request.post?
|
||
|
status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
|
||
|
priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id])
|
||
|
priority = params[:priority_id].blank? ? nil : IssuePriority.find_by_id(params[:priority_id])
|
||
|
assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
|
||
|
category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id])
|
||
|
fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id])
|
||
| ... | ... | |
|
@assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
|
||
|
end
|
||
|
|
||
|
@priorities = Enumeration.priorities.reverse
|
||
|
@priorities = IssuePriority.all.reverse
|
||
|
@statuses = IssueStatus.find(:all, :order => 'position')
|
||
|
@back = request.env['HTTP_REFERER']
|
||
|
|
||
| app/controllers/reports_controller.rb | ||
|---|---|---|
|
render :template => "reports/issue_report_details"
|
||
|
when "priority"
|
||
|
@field = "priority_id"
|
||
|
@rows = Enumeration.priorities
|
||
|
@rows = IssuePriority.all
|
||
|
@data = issues_by_priority
|
||
|
@report_title = l(:field_priority)
|
||
|
render :template => "reports/issue_report_details"
|
||
| ... | ... | |
|
else
|
||
|
@trackers = @project.trackers
|
||
|
@versions = @project.versions.sort
|
||
|
@priorities = Enumeration.priorities
|
||
|
@priorities = IssuePriority.all
|
||
|
@categories = @project.issue_categories
|
||
|
@assignees = @project.members.collect { |m| m.user }
|
||
|
@authors = @project.members.collect { |m| m.user }
|
||
| ... | ... | |
|
p.id as priority_id,
|
||
|
count(i.id) as total
|
||
|
from
|
||
|
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Enumeration.table_name} p
|
||
|
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssuePriority.table_name} p
|
||
|
where
|
||
|
i.status_id=s.id
|
||
|
and i.priority_id=p.id
|
||
| app/controllers/timelog_controller.rb | ||
|---|---|---|
|
:klass => Tracker,
|
||
|
:label => :label_tracker},
|
||
|
'activity' => {:sql => "#{TimeEntry.table_name}.activity_id",
|
||
|
:klass => Enumeration,
|
||
|
:klass => Activity,
|
||
|
:label => :label_activity},
|
||
|
'issue' => {:sql => "#{TimeEntry.table_name}.issue_id",
|
||
|
:klass => Issue,
|
||
| app/helpers/issues_helper.rb | ||
|---|---|---|
|
u = User.find_by_id(detail.value) and value = u.name if detail.value
|
||
|
u = User.find_by_id(detail.old_value) and old_value = u.name if detail.old_value
|
||
|
when 'priority_id'
|
||
|
e = Enumeration.find_by_id(detail.value) and value = e.name if detail.value
|
||
|
e = Enumeration.find_by_id(detail.old_value) and old_value = e.name if detail.old_value
|
||
|
e = IssuePriority.find_by_id(detail.value) and value = e.name if detail.value
|
||
|
e = IssuePriority.find_by_id(detail.old_value) and old_value = e.name if detail.old_value
|
||
|
when 'category_id'
|
||
|
c = IssueCategory.find_by_id(detail.value) and value = c.name if detail.value
|
||
|
c = IssueCategory.find_by_id(detail.old_value) and old_value = c.name if detail.old_value
|
||
| app/helpers/timelog_helper.rb | ||
|---|---|---|
|
end
|
||
|
|
||
|
def activity_collection_for_select_options
|
||
|
activities = Enumeration.activities
|
||
|
activities = Activity.all
|
||
|
collection = []
|
||
|
collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
|
||
|
activities.each { |a| collection << [a.name, a.id] }
|
||
| app/models/activity.rb | ||
|---|---|---|
|
# redMine - project management software
|
||
|
# Copyright (C) 2006 Jean-Philippe Lang
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
class Activity < Enumeration
|
||
|
OptionName = :enumeration_activities
|
||
|
|
||
|
def option_name
|
||
|
OptionName
|
||
|
end
|
||
|
def objects_count
|
||
|
TimeEntry.count(:conditions => "activity_id = #{id}")
|
||
|
end
|
||
|
def transfer_relations(to)
|
||
|
TimeEntry.update_all("activity_id = #{to.id}", "activity_id = #{id}")
|
||
|
end
|
||
|
end
|
||
| app/models/document.rb | ||
|---|---|---|
|
class Document < ActiveRecord::Base
|
||
|
belongs_to :project
|
||
|
belongs_to :category, :class_name => "Enumeration", :foreign_key => "category_id"
|
||
|
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
||
|
acts_as_attachable :delete_permission => :manage_documents
|
||
|
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
|
||
| ... | ... | |
|
|
||
|
def after_initialize
|
||
|
if new_record?
|
||
|
self.category ||= Enumeration.document_categories.default
|
||
|
self.category ||= DocumentCategory.default
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/models/document_category.rb | ||
|---|---|---|
|
# redMine - project management software
|
||
|
# Copyright (C) 2006 Jean-Philippe Lang
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
class DocumentCategory < Enumeration
|
||
|
OptionName = :enumeration_doc_categories
|
||
|
def option_name
|
||
|
OptionName
|
||
|
end
|
||
|
def objects_count
|
||
|
Document.count(:conditions => "category_id = #{id}")
|
||
|
end
|
||
|
def transfer_relations(to)
|
||
|
Document.update_all("category_id = #{to.id}", "category_id = #{id}")
|
||
|
end
|
||
|
end
|
||
| app/models/enumeration.rb | ||
|---|---|---|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
class Enumeration < ActiveRecord::Base
|
||
|
acts_as_list :scope => 'opt = \'#{opt}\''
|
||
|
acts_as_list :scope => 'type = \'#{type}\''
|
||
|
before_destroy :check_integrity
|
||
|
|
||
|
validates_presence_of :opt, :name
|
||
|
validates_uniqueness_of :name, :scope => [:opt]
|
||
|
validates_presence_of :name
|
||
|
validates_uniqueness_of :name, :scope => [:type]
|
||
|
validates_length_of :name, :maximum => 30
|
||
|
# Single table inheritance would be an option
|
||
|
OPTIONS = {
|
||
|
"IPRI" => {:label => :enumeration_issue_priorities, :model => Issue, :foreign_key => :priority_id, :scope => :priorities},
|
||
|
"DCAT" => {:label => :enumeration_doc_categories, :model => Document, :foreign_key => :category_id, :scope => :document_categories},
|
||
|
"ACTI" => {:label => :enumeration_activities, :model => TimeEntry, :foreign_key => :activity_id, :scope => :activities}
|
||
|
}.freeze
|
||
|
|
||
|
# Creates a named scope for each type of value. The scope has a +default+ method
|
||
|
# that returns the default value, or nil if no value is set as default.
|
||
|
# Example:
|
||
|
# Enumeration.priorities
|
||
|
# Enumeration.priorities.default
|
||
|
OPTIONS.each do |k, v|
|
||
|
next unless v[:scope]
|
||
|
named_scope v[:scope], :conditions => { :opt => k }, :order => 'position' do
|
||
|
def default
|
||
|
find(:first, :conditions => { :is_default => true })
|
||
|
end
|
||
|
# Backwards compatiblity named_scopes.
|
||
|
# Can be removed post-0.9
|
||
|
named_scope :priorities, :conditions => { :type => "IssuePriority" }, :order => 'position' do
|
||
|
ActiveSupport::Deprecation.warn("Enumeration#priorities is deprecated, use the IssuePriority class. (#{Redmine::Info.issue(3007)})")
|
||
|
def default
|
||
|
find(:first, :conditions => { :is_default => true })
|
||
|
end
|
||
|
end
|
||
|
named_scope :document_categories, :conditions => { :type => "DocumentCategory" }, :order => 'position' do
|
||
|
ActiveSupport::Deprecation.warn("Enumeration#document_categories is deprecated, use the DocumentCategories class. (#{Redmine::Info.issue(3007)})")
|
||
|
def default
|
||
|
find(:first, :conditions => { :is_default => true })
|
||
|
end
|
||
|
end
|
||
|
named_scope :activities, :conditions => { :type => "Activity" }, :order => 'position' do
|
||
|
ActiveSupport::Deprecation.warn("Enumeration#activities is deprecated, use the Activity class. (#{Redmine::Info.issue(3007)})")
|
||
|
def default
|
||
|
find(:first, :conditions => { :is_default => true })
|
||
|
end
|
||
|
end
|
||
|
|
||
|
named_scope :values, lambda {|opt| { :conditions => { :opt => opt }, :order => 'position' } } do
|
||
|
named_scope :values, lambda {|opt| { :conditions => { :type => type }, :order => 'position' } } do
|
||
|
def default
|
||
|
find(:first, :conditions => { :is_default => true })
|
||
|
end
|
||
|
end
|
||
|
named_scope :all, :order => 'position'
|
||
|
def self.default
|
||
|
find(:first, :conditions => { :is_default => true })
|
||
|
end
|
||
|
|
||
|
# Overloaded on concrete classes
|
||
|
def option_name
|
||
|
OPTIONS[self.opt][:label]
|
||
|
nil
|
||
|
end
|
||
|
def before_save
|
||
|
if is_default? && is_default_changed?
|
||
|
Enumeration.update_all("is_default = #{connection.quoted_false}", {:opt => opt})
|
||
|
Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type})
|
||
|
end
|
||
|
end
|
||
|
|
||
|
# Overloaded on concrete classes
|
||
|
def objects_count
|
||
|
OPTIONS[self.opt][:model].count(:conditions => "#{OPTIONS[self.opt][:foreign_key]} = #{id}")
|
||
|
0
|
||
|
end
|
||
|
|
||
|
def in_use?
|
||
| ... | ... | |
|
# If a enumeration is specified, objects are reassigned
|
||
|
def destroy(reassign_to = nil)
|
||
|
if reassign_to && reassign_to.is_a?(Enumeration)
|
||
|
OPTIONS[self.opt][:model].update_all("#{OPTIONS[self.opt][:foreign_key]} = #{reassign_to.id}", "#{OPTIONS[self.opt][:foreign_key]} = #{id}")
|
||
|
self.transfer_relations(reassign_to)
|
||
|
end
|
||
|
destroy_without_reassign
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
def to_s; name end
|
||
|
# Returns the Subclasses of Enumeration. Each Subclass needs to be
|
||
|
# required in development mode.
|
||
|
#
|
||
|
# Note: subclasses is protected in ActiveRecord
|
||
|
def self.get_subclasses
|
||
|
@@subclasses[Enumeration]
|
||
|
end
|
||
|
|
||
|
private
|
||
|
def check_integrity
|
||
|
raise "Can't delete enumeration" if self.in_use?
|
||
|
end
|
||
|
end
|
||
|
# Force load the subclasses in development mode
|
||
|
require_dependency 'activity'
|
||
|
require_dependency 'document_category'
|
||
|
require_dependency 'issue_priority'
|
||
| app/models/issue.rb | ||
|---|---|---|
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||
|
belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
|
||
|
belongs_to :fixed_version, :class_name => 'Version', :foreign_key => 'fixed_version_id'
|
||
|
belongs_to :priority, :class_name => 'Enumeration', :foreign_key => 'priority_id'
|
||
|
belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id'
|
||
|
belongs_to :category, :class_name => 'IssueCategory', :foreign_key => 'category_id'
|
||
|
has_many :journals, :as => :journalized, :dependent => :destroy
|
||
| ... | ... | |
|
if new_record?
|
||
|
# set default values for new records only
|
||
|
self.status ||= IssueStatus.default
|
||
|
self.priority ||= Enumeration.priorities.default
|
||
|
self.priority ||= IssuePriority.default
|
||
|
end
|
||
|
end
|
||
|
|
||
| app/models/issue_priority.rb | ||
|---|---|---|
|
# redMine - project management software
|
||
|
# Copyright (C) 2006 Jean-Philippe Lang
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
class IssuePriority < Enumeration
|
||
|
OptionName = :enumeration_issue_priorities
|
||
|
def option_name
|
||
|
OptionName
|
||
|
end
|
||
|
def objects_count
|
||
|
Issue.count(:conditions => "priority_id = #{id}")
|
||
|
end
|
||
|
def transfer_relations(to)
|
||
|
Issue.update_all("priority_id = #{to.id}", "priority_id = #{id}")
|
||
|
end
|
||
|
end
|
||
| app/models/mail_handler.rb | ||
|---|---|---|
|
project = target_project
|
||
|
tracker = (get_keyword(:tracker) && project.trackers.find_by_name(get_keyword(:tracker))) || project.trackers.find(:first)
|
||
|
category = (get_keyword(:category) && project.issue_categories.find_by_name(get_keyword(:category)))
|
||
|
priority = (get_keyword(:priority) && Enumeration.find_by_opt_and_name('IPRI', get_keyword(:priority)))
|
||
|
priority = (get_keyword(:priority) && IssuePriority.find_by_name(get_keyword(:priority)))
|
||
|
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
|
||
|
# check permission
|
||
| app/models/query.rb | ||
|---|---|---|
|
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name"),
|
||
|
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position"),
|
||
|
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position"),
|
||
|
QueryColumn.new(:priority, :sortable => "#{Enumeration.table_name}.position", :default_order => 'desc'),
|
||
|
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc'),
|
||
|
QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
|
||
|
QueryColumn.new(:author),
|
||
|
QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname"]),
|
||
| ... | ... | |
|
|
||
|
@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 => Enumeration.find(:all, :conditions => ['opt=?','IPRI'], :order => 'position').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 },
|
||
| app/models/time_entry.rb | ||
|---|---|---|
|
belongs_to :project
|
||
|
belongs_to :issue
|
||
|
belongs_to :user
|
||
|
belongs_to :activity, :class_name => 'Enumeration', :foreign_key => :activity_id
|
||
|
belongs_to :activity
|
||
|
|
||
|
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
||
| ... | ... | |
|
def after_initialize
|
||
|
if new_record? && self.activity.nil?
|
||
|
if default_activity = Enumeration.activities.default
|
||
|
if default_activity = Activity.default
|
||
|
self.activity_id = default_activity.id
|
||
|
end
|
||
|
end
|
||
| app/views/documents/_form.rhtml | ||
|---|---|---|
|
<div class="box">
|
||
|
<!--[form:document]-->
|
||
|
<p><label for="document_category_id"><%=l(:field_category)%></label>
|
||
|
<%= select('document', 'category_id', Enumeration.document_categories.collect {|c| [c.name, c.id]}) %></p>
|
||
|
<%= select('document', 'category_id', DocumentCategory.all.collect {|c| [c.name, c.id]}) %></p>
|
||
|
<p><label for="document_title"><%=l(:field_title)%> <span class="required">*</span></label>
|
||
|
<%= text_field 'document', 'title', :size => 60 %></p>
|
||
| app/views/enumerations/list.rhtml | ||
|---|---|---|
|
<h2><%=l(:label_enumerations)%></h2>
|
||
|
<% Enumeration::OPTIONS.each do |option, params| %>
|
||
|
<h3><%= l(params[:label]) %></h3>
|
||
|
<% Enumeration.get_subclasses.each do |klass| %>
|
||
|
<h3><%= l(klass::OptionName) %></h3>
|
||
|
<% enumerations = Enumeration.values(option) %>
|
||
|
<% enumerations = klass.all %>
|
||
|
<% if enumerations.any? %>
|
||
|
<table class="list">
|
||
|
<% enumerations.each do |enumeration| %>
|
||
| ... | ... | |
|
<% reset_cycle %>
|
||
|
<% end %>
|
||
|
<p><%= link_to l(:label_enumeration_new), { :action => 'new', :opt => option } %></p>
|
||
|
<p><%= link_to l(:label_enumeration_new), { :action => 'new', :type => klass.name } %></p>
|
||
|
<% end %>
|
||
|
<% html_title(l(:label_enumerations)) -%>
|
||
| app/views/issues/bulk_edit.rhtml | ||
|---|---|---|
|
<%= select_tag('status_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@available_statuses, :id, :name)) %></label>
|
||
|
<% end %>
|
||
|
<label><%= l(:field_priority) %>:
|
||
|
<%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(Enumeration.priorities, :id, :name)) %></label>
|
||
|
<%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %></label>
|
||
|
<label><%= l(:field_category) %>:
|
||
|
<%= select_tag('category_id', content_tag('option', l(:label_no_change_option), :value => '') +
|
||
|
content_tag('option', l(:label_none), :value => 'none') +
|
||
| app/views/my/blocks/_issuesassignedtome.rhtml | ||
|---|---|---|
|
:conditions => {:assigned_to_id => User.current.id},
|
||
|
:limit => 10,
|
||
|
:include => [ :status, :project, :tracker, :priority ],
|
||
|
:order => "#{Enumeration.table_name}.position DESC, #{Issue.table_name}.updated_on DESC") %>
|
||
|
:order => "#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC") %>
|
||
|
<%= render :partial => 'issues/list_simple', :locals => { :issues => assigned_issues } %>
|
||
|
<% if assigned_issues.length > 0 %>
|
||
|
<p class="small"><%= link_to l(:label_issue_view_all), :controller => 'issues',
|
||
| db/migrate/20090323224724_change_enumeration_to_sti.rb | ||
|---|---|---|
|
class ChangeEnumerationToSti < ActiveRecord::Migration
|
||
|
def self.up
|
||
|
add_column :enumerations, :type, :string
|
||
|
Enumeration.reset_column_information
|
||
|
Enumeration.update_all("type = 'IssuePriority'", "opt = 'IPRI'")
|
||
|
Enumeration.update_all("type = 'DocumentCategory'", "opt = 'DCAT'")
|
||
|
Enumeration.update_all("type = 'Activity'", "opt = 'ACTI'")
|
||
|
end
|
||
|
def self.down
|
||
|
remove_column :enumerations, :type
|
||
|
end
|
||
|
end
|
||
| lib/redmine/info.rb | ||
|---|---|---|
|
def url; 'http://www.redmine.org/' end
|
||
|
def help_url; 'http://www.redmine.org/guide' end
|
||
|
def versioned_name; "#{app_name} #{Redmine::VERSION}" end
|
||
|
# Creates the url string to a specific Redmine issue
|
||
|
def issue(issue_id)
|
||
|
url + 'issues/' + issue_id.to_s
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| test/fixtures/enumerations.yml | ||
|---|---|---|
|
name: Uncategorized
|
||
|
id: 1
|
||
|
opt: DCAT
|
||
|
type: DocumentCategory
|
||
|
enumerations_002:
|
||
|
name: User documentation
|
||
|
id: 2
|
||
|
opt: DCAT
|
||
|
type: DocumentCategory
|
||
|
enumerations_003:
|
||
|
name: Technical documentation
|
||
|
id: 3
|
||
|
opt: DCAT
|
||
|
type: DocumentCategory
|
||
|
enumerations_004:
|
||
|
name: Low
|
||
|
id: 4
|
||
|
opt: IPRI
|
||
|
type: IssuePriority
|
||
|
enumerations_005:
|
||
|
name: Normal
|
||
|
id: 5
|
||
|
opt: IPRI
|
||
|
type: IssuePriority
|
||
|
is_default: true
|
||
|
enumerations_006:
|
||
|
name: High
|
||
|
id: 6
|
||
|
opt: IPRI
|
||
|
type: IssuePriority
|
||
|
enumerations_007:
|
||
|
name: Urgent
|
||
|
id: 7
|
||
|
opt: IPRI
|
||
|
type: IssuePriority
|
||
|
enumerations_008:
|
||
|
name: Immediate
|
||
|
id: 8
|
||
|
opt: IPRI
|
||
|
type: IssuePriority
|
||
|
enumerations_009:
|
||
|
name: Design
|
||
|
id: 9
|
||
|
opt: ACTI
|
||
|
type: Activity
|
||
|
enumerations_010:
|
||
|
name: Development
|
||
|
id: 10
|
||
|
opt: ACTI
|
||
|
type: Activity
|
||
|
is_default: true
|
||
|
enumerations_011:
|
||
|
name: QA
|
||
|
id: 11
|
||
|
opt: ACTI
|
||
|
|
||
|
type: Activity
|
||
| test/fixtures/issues.yml | ||
|---|---|---|
|
created_on: <%= 10.days.ago.to_date.to_s(:db) %>
|
||
|
project_id: 1
|
||
|
updated_on: <%= 10.days.ago.to_date.to_s(:db) %>
|
||
|
priority_id: 3
|
||
|
priority_id: 5
|
||
|
subject: Issue due today
|
||
|
id: 7
|
||
|
fixed_version_id:
|
||
| ... | ... | |
|
created_on: <%= 10.days.ago.to_date.to_s(:db) %>
|
||
|
project_id: 1
|
||
|
updated_on: <%= 10.days.ago.to_date.to_s(:db) %>
|
||
|
priority_id: 3
|
||
|
priority_id: 5
|
||
|
subject: Closed issue
|
||
|
id: 8
|
||
|
fixed_version_id:
|
||
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
:id => 1,
|
||
|
:issue => { :status_id => 2, :assigned_to_id => 3 },
|
||
|
:notes => 'Assigned to dlopper',
|
||
|
:time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.activities.first }
|
||
|
:time_entry => { :hours => '', :comments => '', :activity_id => Activity.first }
|
||
|
end
|
||
|
assert_redirected_to :action => 'show', :id => '1'
|
||
|
issue.reload
|
||
| ... | ... | |
|
post :edit,
|
||
|
:id => 1,
|
||
|
:notes => '2.5 hours added',
|
||
|
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.activities.first }
|
||
|
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Activity.first }
|
||
|
end
|
||
|
assert_redirected_to :action => 'show', :id => '1'
|
||
|
|
||
| test/integration/issues_test.rb | ||
|---|---|---|
|
|
||
|
post 'projects/1/issues', :tracker_id => "1",
|
||
|
:issue => { :start_date => "2006-12-26",
|
||
|
:priority_id => "3",
|
||
|
:priority_id => "4",
|
||
|
:subject => "new test issue",
|
||
|
:category_id => "",
|
||
|
:description => "new issue",
|
||
| test/unit/enumeration_test.rb | ||
|---|---|---|
|
end
|
||
|
|
||
|
def test_default
|
||
|
e = Enumeration.priorities.default
|
||
|
e = Enumeration.default
|
||
|
assert e.is_a?(Enumeration)
|
||
|
assert e.is_default?
|
||
|
assert_equal 'Normal', e.name
|
||
|
end
|
||
|
|
||
|
def test_create
|
||
|
e = Enumeration.new(:opt => 'IPRI', :name => 'Very urgent', :is_default => false)
|
||
|
e = IssuePriority.new(:type => 'Priority', :name => 'Very urgent', :is_default => false)
|
||
|
assert e.save
|
||
|
assert_equal 'Normal', Enumeration.priorities.default.name
|
||
|
assert_equal 'Normal', IssuePriority.default.name
|
||
|
end
|
||
|
|
||
|
def test_create_as_default
|
||
|
e = Enumeration.new(:opt => 'IPRI', :name => 'Very urgent', :is_default => true)
|
||
|
e = IssuePriority.new(:name => 'Very urgent', :is_default => true)
|
||
|
assert e.save
|
||
|
assert_equal e, Enumeration.priorities.default
|
||
|
assert_equal e, IssuePriority.default
|
||
|
end
|
||
|
|
||
|
def test_update_default
|
||
|
e = Enumeration.priorities.default
|
||
|
e = IssuePriority.default
|
||
|
e.update_attributes(:name => 'Changed', :is_default => true)
|
||
|
assert_equal e, Enumeration.priorities.default
|
||
|
assert_equal e, IssuePriority.default
|
||
|
end
|
||
|
|
||
|
def test_update_default_to_non_default
|
||
|
e = Enumeration.priorities.default
|
||
|
e = IssuePriority.default
|
||
|
e.update_attributes(:name => 'Changed', :is_default => false)
|
||
|
assert_nil Enumeration.priorities.default
|
||
|
assert_nil IssuePriority.default
|
||
|
end
|
||
|
|
||
|
def test_change_default
|
||
|
e = Enumeration.find_by_name('Urgent')
|
||
|
e = IssuePriority.find_by_name('Urgent')
|
||
|
e.update_attributes(:name => 'Urgent', :is_default => true)
|
||
|
assert_equal e, Enumeration.priorities.default
|
||
|
assert_equal e, IssuePriority.default
|
||
|
end
|
||
|
|
||
|
def test_destroy_with_reassign
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
:time_entries
|
||
|
def test_create
|
||
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'test_create', :description => 'IssueTest#test_create', :estimated_hours => '1:30')
|
||
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create', :description => 'IssueTest#test_create', :estimated_hours => '1:30')
|
||
|
assert issue.save
|
||
|
issue.reload
|
||
|
assert_equal 1.5, issue.estimated_hours
|
||
|
end
|
||
|
|
||
|
def test_create_minimal
|
||
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'test_create')
|
||
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create')
|
||
|
assert issue.save
|
||
|
assert issue.description.nil?
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
def test_category_based_assignment
|
||
|
issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
|
||
|
issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
|
||
|
assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
|
||
|
end
|
||
|
|
||
| ... | ... | |
|
|
||
|
def test_should_close_duplicates
|
||
|
# Create 3 issues
|
||
|
issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'Duplicates test', :description => 'Duplicates test')
|
||
|
issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Duplicates test', :description => 'Duplicates test')
|
||
|
assert issue1.save
|
||
|
issue2 = issue1.clone
|
||
|
assert issue2.save
|
||
| ... | ... | |
|
|
||
|
def test_should_not_close_duplicated_issue
|
||
|
# Create 3 issues
|
||
|
issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'Duplicates test', :description => 'Duplicates test')
|
||
|
issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Duplicates test', :description => 'Duplicates test')
|
||
|
assert issue1.save
|
||
|
issue2 = issue1.clone
|
||
|
assert issue2.save
|
||