Feature #8138 ยป 0001-Implemented-IssueCategory-default-Priority-setting.patch
app/controllers/issue_categories_controller.rb | ||
---|---|---|
22 | 22 |
before_filter :find_project_from_association, :except => :new |
23 | 23 |
before_filter :find_project, :only => :new |
24 | 24 |
before_filter :authorize |
25 |
before_filter :find_priorities |
|
25 | 26 |
|
26 | 27 |
verify :method => :post, :only => :destroy |
27 | 28 | |
28 | 29 |
def new |
29 | 30 |
@category = @project.issue_categories.build(params[:category]) |
31 |
logger.debug "priority #{params[:priority]}" |
|
30 | 32 |
if request.post? |
31 | 33 |
if @category.save |
32 | 34 |
respond_to do |format| |
... | ... | |
86 | 88 |
rescue ActiveRecord::RecordNotFound |
87 | 89 |
render_404 |
88 | 90 |
end |
91 | ||
92 |
def find_priorities |
|
93 |
@priorities = IssuePriority.all |
|
94 |
end |
|
89 | 95 |
end |
app/models/issue.rb | ||
---|---|---|
81 | 81 |
} |
82 | 82 |
} |
83 | 83 | |
84 |
before_create :default_assign |
|
84 |
before_create :default_assign, :default_priority
|
|
85 | 85 |
before_save :close_duplicates, :update_done_ratio_from_issue_status |
86 | 86 |
after_save :reschedule_following_issues, :update_nested_set_attributes, :update_parent_attributes, :create_journal |
87 | 87 |
after_destroy :update_parent_attributes |
... | ... | |
831 | 831 |
end |
832 | 832 |
end |
833 | 833 | |
834 |
# Priority assignment based on category |
|
835 |
def default_priority |
|
836 |
if category && category.priority |
|
837 |
self.priority = category.priority |
|
838 |
end |
|
839 |
end |
|
840 | ||
834 | 841 |
# Updates start/due dates of following issues |
835 | 842 |
def reschedule_following_issues |
836 | 843 |
if start_date_changed? || due_date_changed? |
app/models/issue_category.rb | ||
---|---|---|
18 | 18 |
class IssueCategory < ActiveRecord::Base |
19 | 19 |
belongs_to :project |
20 | 20 |
belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id' |
21 |
belongs_to :priority, :class_name => 'IssuePriority', :foreign_key => 'priority_id' |
|
21 | 22 |
has_many :issues, :foreign_key => 'category_id', :dependent => :nullify |
22 | 23 |
|
23 | 24 |
validates_presence_of :name |
app/views/issue_categories/_form.rhtml | ||
---|---|---|
3 | 3 |
<div class="box"> |
4 | 4 |
<p><%= f.text_field :name, :size => 30, :required => true %></p> |
5 | 5 |
<p><%= f.select :assigned_to_id, @project.users.sort.collect{|u| [u.name, u.id]}, :include_blank => true %></p> |
6 |
<p><%= f.select :priority_id, @priorities.collect{|u| [u.name, u.id]}, :include_blank => true %></p> |
|
6 | 7 |
</div> |
db/migrate/20110418110400_add_default_priority_to_issue_category.rb | ||
---|---|---|
1 |
class AddDefaultPriorityToIssueCategory < ActiveRecord::Migration |
|
2 |
def self.up |
|
3 |
add_column :issue_categories, :priority_id, :integer |
|
4 |
end |
|
5 |
def self.down |
|
6 |
remove_column :issue_categories, :priority_id |
|
7 |
end |
|
8 |
end |