]> source.dussan.org Git - redmine.git/commitdiff
Feature 9784 Set status when raising issue.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 3 Apr 2007 18:34:22 +0000 (18:34 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 3 Apr 2007 18:34:22 +0000 (18:34 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@407 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/models/issue.rb
app/views/projects/add_issue.rhtml

index 5f188a4dd3b7606f11238407e69555ed0be57dd9..a778e5af2fd7e930e3dc8be20fbb8492d5e06296 100644 (file)
@@ -212,12 +212,20 @@ class ProjectsController < ApplicationController
   def add_issue
     @tracker = Tracker.find(params[:tracker_id])
     @priorities = Enumeration::get_values('IPRI')
-    @issue = Issue.new(:project => @project, :tracker => @tracker)
+    
+    default_status = IssueStatus.default
+    @issue = Issue.new(:project => @project, :tracker => @tracker, :status => default_status)    
+    @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 }
+    
     if request.get?
       @issue.start_date = Date.today
       @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
     else
       @issue.attributes = params[:issue]
+      
+      requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
+      @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
+      
       @issue.author_id = self.logged_in_user.id if self.logged_in_user
       # Multiple file upload
       @attachments = []
index dd512017f61584508e550eb85040b555aa7c0197..bb7797c402246aa139723dc8492df7796718c757 100644 (file)
@@ -38,7 +38,7 @@ class Issue < ActiveRecord::Base
 
   # set default status for new issues
   def before_validation
-    self.status = IssueStatus.default if new_record?
+    self.status = IssueStatus.default if status.nil?
   end
 
   def validate
index 4f592ff7aded87e9dab89f25a628e1641c610283..36c6d5869bdf0d758817bad529a68cdcdea1d157 100644 (file)
@@ -7,6 +7,7 @@
 <%= hidden_field_tag 'tracker_id', @tracker.id %>
 
 <div class="splitcontentleft">
+<p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p>
 <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
 <p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
 <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %></p>