@@ -212,12 +212,20 class ProjectsController < ApplicationController | |||||
212 | def add_issue |
|
212 | def add_issue | |
213 | @tracker = Tracker.find(params[:tracker_id]) |
|
213 | @tracker = Tracker.find(params[:tracker_id]) | |
214 | @priorities = Enumeration::get_values('IPRI') |
|
214 | @priorities = Enumeration::get_values('IPRI') | |
215 | @issue = Issue.new(:project => @project, :tracker => @tracker) |
|
215 | ||
|
216 | default_status = IssueStatus.default | |||
|
217 | @issue = Issue.new(:project => @project, :tracker => @tracker, :status => default_status) | |||
|
218 | @allowed_statuses = [default_status] + default_status.workflows.find(:all, :order => 'position', :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } | |||
|
219 | ||||
216 | if request.get? |
|
220 | if request.get? | |
217 | @issue.start_date = Date.today |
|
221 | @issue.start_date = Date.today | |
218 | @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } |
|
222 | @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } | |
219 | else |
|
223 | else | |
220 | @issue.attributes = params[:issue] |
|
224 | @issue.attributes = params[:issue] | |
|
225 | ||||
|
226 | requested_status = IssueStatus.find_by_id(params[:issue][:status_id]) | |||
|
227 | @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status | |||
|
228 | ||||
221 | @issue.author_id = self.logged_in_user.id if self.logged_in_user |
|
229 | @issue.author_id = self.logged_in_user.id if self.logged_in_user | |
222 | # Multiple file upload |
|
230 | # Multiple file upload | |
223 | @attachments = [] |
|
231 | @attachments = [] |
@@ -38,7 +38,7 class Issue < ActiveRecord::Base | |||||
38 |
|
38 | |||
39 | # set default status for new issues |
|
39 | # set default status for new issues | |
40 | def before_validation |
|
40 | def before_validation | |
41 |
self.status = IssueStatus.default if |
|
41 | self.status = IssueStatus.default if status.nil? | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | def validate |
|
44 | def validate |
@@ -7,6 +7,7 | |||||
7 | <%= hidden_field_tag 'tracker_id', @tracker.id %> |
|
7 | <%= hidden_field_tag 'tracker_id', @tracker.id %> | |
8 |
|
8 | |||
9 | <div class="splitcontentleft"> |
|
9 | <div class="splitcontentleft"> | |
|
10 | <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p> | |||
10 | <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p> |
|
11 | <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p> | |
11 | <p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p> |
|
12 | <p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p> | |
12 | <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %></p> |
|
13 | <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %></p> |
General Comments 0
You need to be logged in to leave comments.
Login now