diff app/controllers/projects_controller.rb @ 912:5e80956cc792 cannam_integration

Merge from branch "redmine-1.3"
author Chris Cannam
date Mon, 27 Feb 2012 13:53:18 +0000
parents 7614169e14ed cbb26bc654de
children 2a68662d5adf
line wrap: on
line diff
--- a/app/controllers/projects_controller.rb	Fri Feb 24 20:18:25 2012 +0000
+++ b/app/controllers/projects_controller.rb	Mon Feb 27 13:53:18 2012 +0000
@@ -5,12 +5,12 @@
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
@@ -19,7 +19,7 @@
   menu_item :overview
   menu_item :roadmap, :only => :roadmap
   menu_item :settings, :only => :settings
-  
+
   before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
   before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
   before_filter :authorize_global, :only => [:new, :create]
@@ -36,7 +36,7 @@
   helper :sort
   include SortHelper
   helper :custom_fields
-  include CustomFieldsHelper   
+  include CustomFieldsHelper
   helper :issues
   helper :queries
   include QueriesHelper
@@ -48,7 +48,7 @@
   # (subprojects belong to them)
   def index
     respond_to do |format|
-      format.html { 
+      format.html {
         sort_init 'name'
         sort_update %w(name lft created_on updated_on)
         @limit = per_page_option
@@ -75,7 +75,7 @@
       }
     end
   end
-  
+
   def new
     @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
     @trackers = Tracker.all
@@ -108,9 +108,12 @@
         @project.members << m
       end
       respond_to do |format|
-        format.html { 
+        format.html {
           flash[:notice] = l(:notice_successful_create)
-          redirect_to :controller => 'projects', :action => 'settings', :id => @project
+          redirect_to(params[:continue] ?
+            {:controller => 'projects', :action => 'new', :project => {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}} :
+            {:controller => 'projects', :action => 'settings', :id => @project}
+          )
         }
         format.api  { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
       end
@@ -120,9 +123,9 @@
         format.api  { render_validation_errors(@project) }
       end
     end
-    
+
   end
-  
+
   def copy
     @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
     @trackers = Tracker.all
@@ -136,7 +139,7 @@
         @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
       else
         redirect_to :controller => 'admin', :action => 'projects'
-      end  
+      end
     else
       Mailer.with_deliveries(params[:notifications] == '1') do
         @project = Project.new
@@ -164,27 +167,27 @@
       # try to redirect to the requested menu item
       redirect_to_project_menu_item(@project, params[:jump]) && return
     end
-    
+
     @users_by_role = @project.users_by_role
     @subprojects = @project.children.visible.all
     @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
     @trackers = @project.rolled_up_trackers
-    
+
     cond = @project.project_condition(Setting.display_subprojects_issues?)
-    
+
     @open_issues_by_tracker = Issue.visible.count(:group => :tracker,
                                             :include => [:project, :status, :tracker],
                                             :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false])
     @total_issues_by_tracker = Issue.visible.count(:group => :tracker,
                                             :include => [:project, :status, :tracker],
                                             :conditions => cond)
-    
+
     if User.current.allowed_to?(:view_time_entries, @project)
       @total_hours = TimeEntry.visible.sum(:hours, :include => :project, :conditions => cond).to_f
     end
-    
+
     @key = User.current.rss_key
-    
+
     respond_to do |format|
       format.html
       format.api
@@ -199,7 +202,7 @@
     @repository ||= @project.repository
     @wiki ||= @project.wiki
   end
-  
+
   def edit
   end
 
@@ -210,7 +213,7 @@
     if validate_parent_id && @project.save
       @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
       respond_to do |format|
-        format.html { 
+        format.html {
           flash[:notice] = l(:notice_successful_update)
           redirect_to :action => 'settings', :id => @project
         }
@@ -218,7 +221,7 @@
       end
     else
       respond_to do |format|
-        format.html { 
+        format.html {
           settings
           render :action => 'settings'
         }
@@ -251,12 +254,12 @@
     end
     redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
   end
-  
+
   def unarchive
     @project.unarchive if request.post? && !@project.active?
     redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status]))
   end
-  
+
   # Delete @project
   def destroy
     @project_to_destroy = @project