Feature #8138 ยป 0001-Implemented-IssueCategory-default-Priority-setting.patch
| app/controllers/issue_categories_controller.rb | ||
|---|---|---|
|
before_filter :find_project_from_association, :except => :new
|
||
|
before_filter :find_project, :only => :new
|
||
|
before_filter :authorize
|
||
|
before_filter :find_priorities
|
||
|
|
||
|
verify :method => :post, :only => :destroy
|
||
|
def new
|
||
|
@category = @project.issue_categories.build(params[:category])
|
||
|
logger.debug "priority #{params[:priority]}"
|
||
|
if request.post?
|
||
|
if @category.save
|
||
|
respond_to do |format|
|
||
| ... | ... | |
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
def find_priorities
|
||
|
@priorities = IssuePriority.all
|
||
|
end
|
||
|
end
|
||
| app/models/issue.rb | ||
|---|---|---|
|
}
|
||
|
}
|
||
|
before_create :default_assign
|
||
|
before_create :default_assign, :default_priority
|
||
|
before_save :close_duplicates, :update_done_ratio_from_issue_status
|
||
|
after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal
|
||
|
after_destroy :update_parent_attributes
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
# Priority assignment based on category
|
||
|
def default_priority
|
||
|
if category && category.priority
|
||
|
self.priority = category.priority
|
||
|
end
|
||
|
end
|
||
|
# Updates start/due dates of following issues
|
||
|
def reschedule_following_issues
|
||
|
if start_date_changed? || due_date_changed?
|
||
| app/models/issue_category.rb | ||
|---|---|---|
|
class IssueCategory < ActiveRecord::Base
|
||
|
belongs_to :project
|
||
|
belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
|
||
|
belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id'
|
||
|
has_many :issues, :foreign_key => 'category_id', :dependent => :nullify
|
||
|
|
||
|
validates_presence_of :name
|
||
| app/views/issue_categories/_form.rhtml | ||
|---|---|---|
|
<div class="box">
|
||
|
<p><%= f.text_field :name, :size => 30, :required => true %></p>
|
||
|
<p><%= f.select :assigned_to_id, @project.users.sort.collect{|u| [u.name, u.id]}, :include_blank => true %></p>
|
||
|
<p><%= f.select :priority_id, @priorities.collect{|u| [u.name, u.id]}, :include_blank => true %></p>
|
||
|
</div>
|
||
| db/migrate/20110418110400_add_default_priority_to_issue_category.rb | ||
|---|---|---|
|
class AddDefaultPriorityToIssueCategory < ActiveRecord::Migration
|
||
|
def self.up
|
||
|
add_column :issue_categories, :priority_id, :integer
|
||
|
end
|
||
|
def self.down
|
||
|
remove_column :issue_categories, :priority_id
|
||
|
end
|
||
|
end
|
||