##// END OF EJS Templates
Feature 9784 Set status when raising issue....
Jean-Philippe Lang -
r404:a09b2a23b912
parent child
Show More
@@ -212,12 +212,20 class ProjectsController < ApplicationController
212 212 def add_issue
213 213 @tracker = Tracker.find(params[:tracker_id])
214 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 220 if request.get?
217 221 @issue.start_date = Date.today
218 222 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
219 223 else
220 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 229 @issue.author_id = self.logged_in_user.id if self.logged_in_user
222 230 # Multiple file upload
223 231 @attachments = []
@@ -38,7 +38,7 class Issue < ActiveRecord::Base
38 38
39 39 # set default status for new issues
40 40 def before_validation
41 self.status = IssueStatus.default if new_record?
41 self.status = IssueStatus.default if status.nil?
42 42 end
43 43
44 44 def validate
@@ -7,6 +7,7
7 7 <%= hidden_field_tag 'tracker_id', @tracker.id %>
8 8
9 9 <div class="splitcontentleft">
10 <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p>
10 11 <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
11 12 <p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
12 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