2007-03-12 20:59:02 +03:00
|
|
|
# redMine - project management software
|
|
|
|
# Copyright (C) 2006 Jean-Philippe Lang
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
class VersionsController < ApplicationController
|
2008-01-19 14:53:43 +03:00
|
|
|
menu_item :roadmap
|
2009-11-09 21:53:12 +03:00
|
|
|
before_filter :find_version, :except => :close_completed
|
|
|
|
before_filter :find_project, :only => :close_completed
|
|
|
|
before_filter :authorize
|
2006-07-30 14:47:02 +04:00
|
|
|
|
2009-11-15 18:22:55 +03:00
|
|
|
helper :custom_fields
|
2009-12-06 13:28:20 +03:00
|
|
|
helper :projects
|
2009-11-15 18:22:55 +03:00
|
|
|
|
2007-12-07 13:26:07 +03:00
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2006-07-30 14:47:02 +04:00
|
|
|
def edit
|
2009-12-06 13:28:20 +03:00
|
|
|
if request.post? && params[:version]
|
|
|
|
attributes = params[:version].dup
|
|
|
|
attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
|
|
|
|
if @version.update_attributes(attributes)
|
|
|
|
flash[:notice] = l(:notice_successful_update)
|
|
|
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
|
|
|
end
|
2006-07-30 14:47:02 +04:00
|
|
|
end
|
|
|
|
end
|
2009-11-09 21:53:12 +03:00
|
|
|
|
|
|
|
def close_completed
|
|
|
|
if request.post?
|
|
|
|
@project.close_completed_versions
|
|
|
|
end
|
|
|
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
|
|
|
end
|
2006-07-30 14:47:02 +04:00
|
|
|
|
2007-03-12 20:59:02 +03:00
|
|
|
def destroy
|
2006-07-30 14:47:02 +04:00
|
|
|
@version.destroy
|
2007-03-12 20:59:02 +03:00
|
|
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
|
|
|
rescue
|
2008-09-14 16:59:12 +04:00
|
|
|
flash[:error] = l(:notice_unable_delete_version)
|
2007-03-12 20:59:02 +03:00
|
|
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
|
|
|
end
|
|
|
|
|
2007-12-07 13:26:07 +03:00
|
|
|
def status_by
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { render :action => 'show' }
|
|
|
|
format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} }
|
|
|
|
end
|
|
|
|
end
|
2007-03-12 20:59:02 +03:00
|
|
|
|
|
|
|
private
|
2009-11-09 21:53:12 +03:00
|
|
|
def find_version
|
2007-03-12 20:59:02 +03:00
|
|
|
@version = Version.find(params[:id])
|
|
|
|
@project = @version.project
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render_404
|
2009-11-09 21:53:12 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def find_project
|
|
|
|
@project = Project.find(params[:project_id])
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render_404
|
|
|
|
end
|
2006-06-28 22:11:03 +04:00
|
|
|
end
|