Patch #1667 » default_tracker.patch
app/controllers/issues_controller.rb (working copy) | ||
---|---|---|
116 | 116 |
@issue.copy_from(params[:copy_from]) if params[:copy_from] |
117 | 117 |
@issue.project = @project |
118 | 118 |
# Tracker must be set before custom field values |
119 |
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) |
|
120 |
if @issue.tracker.nil? |
|
121 |
flash.now[:error] = 'No tracker is associated to this project. Please check the Project settings.' |
|
122 |
render :nothing => true, :layout => true |
|
123 |
return |
|
119 |
unless @issue.tracker |
|
120 |
if @project.trackers.empty? |
|
121 |
flash.now[:error] = 'No tracker is associated to this project. Please check the Project settings.' |
|
122 |
render :nothing => true, :layout => true |
|
123 |
return |
|
124 |
end |
|
125 |
tracker_id = (params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] |
|
126 |
@issue.tracker = @project.trackers.find_by_id(tracker_id) unless tracker_id.blank? |
|
127 |
@issue.tracker ||= @project.trackers.find_by_id(@project.default_tracker_id) |
|
124 | 128 |
end |
125 | 129 |
@issue.attributes = params[:issue] |
126 | 130 |
@issue.author = User.current |
app/models/issue.rb (working copy) | ||
---|---|---|
116 | 116 |
end |
117 | 117 |
|
118 | 118 |
def validate_on_create |
119 |
errors.add :tracker_id, :activerecord_error_invalid unless project.trackers.include?(tracker)
|
|
119 |
errors.add :tracker_id, :activerecord_error_invalid if !tracker.blank? && !project.trackers.include?(tracker)
|
|
120 | 120 |
end |
121 | 121 |
|
122 | 122 |
def before_create |
app/views/issues/_form.rhtml (working copy) | ||
---|---|---|
1 | 1 |
<% if @issue.new_record? %> |
2 |
<p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p>
|
|
2 |
<p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, {:required => true, :include_blank => true} %></p>
|
|
3 | 3 |
<%= observe_field :issue_tracker_id, :url => { :action => :new }, |
4 | 4 |
:update => :content, |
5 | 5 |
:with => "Form.serialize('issue-form')" %> |
app/views/projects/_form.rhtml (working copy) | ||
---|---|---|
20 | 20 |
<% @project.custom_field_values.each do |value| %> |
21 | 21 |
<p><%= custom_field_tag_with_label :project, value %></p> |
22 | 22 |
<% end %> |
23 |
<p><%= f.select :default_tracker_id, (@trackers.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p> |
|
23 | 24 |
</div> |
24 | 25 | |
25 | 26 |
<% unless @trackers.empty? %> |
db/migrate/095_add_default_tracker_id.rb (revision 0) | ||
---|---|---|
1 |
class AddDefaultTrackerId < ActiveRecord::Migration |
|
2 |
def self.up |
|
3 |
add_column :projects, :default_tracker_id, :integer |
|
4 |
end |
|
5 | ||
6 |
def self.down |
|
7 |
remove_column :projects, :default_tracker_id |
|
8 |
end |
|
9 |
end |
lang/en.yml (working copy) | ||
---|---|---|
182 | 182 |
field_searchable: Searchable |
183 | 183 |
field_default_value: Default value |
184 | 184 |
field_comments_sorting: Display comments |
185 |
field_default_tracker: Default tracker |
|
185 | 186 | |
186 | 187 |
setting_app_title: Application title |
187 | 188 |
setting_app_subtitle: Application subtitle |