comparison app/controllers/versions_controller.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
29 helper :projects 29 helper :projects
30 30
31 def index 31 def index
32 respond_to do |format| 32 respond_to do |format|
33 format.html { 33 format.html {
34 @trackers = @project.trackers.find(:all, :order => 'position') 34 @trackers = @project.trackers.sorted.all
35 retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?}) 35 retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
36 @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') 36 @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
37 project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id] 37 project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
38 38
39 @versions = @project.shared_versions || [] 39 @versions = @project.shared_versions || []
62 end 62 end
63 63
64 def show 64 def show
65 respond_to do |format| 65 respond_to do |format|
66 format.html { 66 format.html {
67 @issues = @version.fixed_issues.visible.find(:all, 67 @issues = @version.fixed_issues.visible.
68 :include => [:status, :tracker, :priority], 68 includes(:status, :tracker, :priority).
69 :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") 69 reorder("#{Tracker.table_name}.position, #{Issue.table_name}.id").
70 all
70 } 71 }
71 format.api 72 format.api
72 end 73 end
73 end 74 end
74 75
93 if request.post? 94 if request.post?
94 if @version.save 95 if @version.save
95 respond_to do |format| 96 respond_to do |format|
96 format.html do 97 format.html do
97 flash[:notice] = l(:notice_successful_create) 98 flash[:notice] = l(:notice_successful_create)
98 redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project 99 redirect_back_or_default settings_project_path(@project, :tab => 'versions')
99 end 100 end
100 format.js 101 format.js
101 format.api do 102 format.api do
102 render :action => 'show', :status => :created, :location => version_url(@version) 103 render :action => 'show', :status => :created, :location => version_url(@version)
103 end 104 end
122 @version.safe_attributes = attributes 123 @version.safe_attributes = attributes
123 if @version.save 124 if @version.save
124 respond_to do |format| 125 respond_to do |format|
125 format.html { 126 format.html {
126 flash[:notice] = l(:notice_successful_update) 127 flash[:notice] = l(:notice_successful_update)
127 redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project 128 redirect_back_or_default settings_project_path(@project, :tab => 'versions')
128 } 129 }
129 format.api { render_api_ok } 130 format.api { render_api_ok }
130 end 131 end
131 else 132 else
132 respond_to do |format| 133 respond_to do |format|
139 140
140 def close_completed 141 def close_completed
141 if request.put? 142 if request.put?
142 @project.close_completed_versions 143 @project.close_completed_versions
143 end 144 end
144 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project 145 redirect_to settings_project_path(@project, :tab => 'versions')
145 end 146 end
146 147
147 def destroy 148 def destroy
148 if @version.fixed_issues.empty? 149 if @version.fixed_issues.empty?
149 @version.destroy 150 @version.destroy
150 respond_to do |format| 151 respond_to do |format|
151 format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project } 152 format.html { redirect_back_or_default settings_project_path(@project, :tab => 'versions') }
152 format.api { render_api_ok } 153 format.api { render_api_ok }
153 end 154 end
154 else 155 else
155 respond_to do |format| 156 respond_to do |format|
156 format.html { 157 format.html {
157 flash[:error] = l(:notice_unable_delete_version) 158 flash[:error] = l(:notice_unable_delete_version)
158 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project 159 redirect_to settings_project_path(@project, :tab => 'versions')
159 } 160 }
160 format.api { head :unprocessable_entity } 161 format.api { head :unprocessable_entity }
161 end 162 end
162 end 163 end
163 end 164 end