@@ -1,108 +1,108 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class VersionsController < ApplicationController |
|
19 | 19 | menu_item :roadmap |
|
20 | 20 | model_object Version |
|
21 | 21 | before_filter :find_model_object, :except => [:new, :close_completed] |
|
22 | 22 | before_filter :find_project_from_association, :except => [:new, :close_completed] |
|
23 | 23 | before_filter :find_project, :only => [:new, :close_completed] |
|
24 | 24 | before_filter :authorize |
|
25 | 25 | |
|
26 | 26 | helper :custom_fields |
|
27 | 27 | helper :projects |
|
28 | 28 | |
|
29 | 29 | def show |
|
30 | @issues = @version.fixed_issues.find(:all, | |
|
30 | @issues = @version.fixed_issues.visible.find(:all, | |
|
31 | 31 | :include => [:status, :tracker, :priority], |
|
32 | 32 | :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | def new |
|
36 | 36 | @version = @project.versions.build |
|
37 | 37 | if params[:version] |
|
38 | 38 | attributes = params[:version].dup |
|
39 | 39 | attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) |
|
40 | 40 | @version.attributes = attributes |
|
41 | 41 | end |
|
42 | 42 | if request.post? |
|
43 | 43 | if @version.save |
|
44 | 44 | respond_to do |format| |
|
45 | 45 | format.html do |
|
46 | 46 | flash[:notice] = l(:notice_successful_create) |
|
47 | 47 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
48 | 48 | end |
|
49 | 49 | format.js do |
|
50 | 50 | # IE doesn't support the replace_html rjs method for select box options |
|
51 | 51 | render(:update) {|page| page.replace "issue_fixed_version_id", |
|
52 | 52 | content_tag('select', '<option></option>' + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') |
|
53 | 53 | } |
|
54 | 54 | end |
|
55 | 55 | end |
|
56 | 56 | else |
|
57 | 57 | respond_to do |format| |
|
58 | 58 | format.html |
|
59 | 59 | format.js do |
|
60 | 60 | render(:update) {|page| page.alert(@version.errors.full_messages.join('\n')) } |
|
61 | 61 | end |
|
62 | 62 | end |
|
63 | 63 | end |
|
64 | 64 | end |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | def edit |
|
68 | 68 | if request.post? && params[:version] |
|
69 | 69 | attributes = params[:version].dup |
|
70 | 70 | attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) |
|
71 | 71 | if @version.update_attributes(attributes) |
|
72 | 72 | flash[:notice] = l(:notice_successful_update) |
|
73 | 73 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
74 | 74 | end |
|
75 | 75 | end |
|
76 | 76 | end |
|
77 | 77 | |
|
78 | 78 | def close_completed |
|
79 | 79 | if request.post? |
|
80 | 80 | @project.close_completed_versions |
|
81 | 81 | end |
|
82 | 82 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
83 | 83 | end |
|
84 | 84 | |
|
85 | 85 | def destroy |
|
86 | 86 | if @version.fixed_issues.empty? |
|
87 | 87 | @version.destroy |
|
88 | 88 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
89 | 89 | else |
|
90 | 90 | flash[:error] = l(:notice_unable_delete_version) |
|
91 | 91 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
92 | 92 | end |
|
93 | 93 | end |
|
94 | 94 | |
|
95 | 95 | def status_by |
|
96 | 96 | respond_to do |format| |
|
97 | 97 | format.html { render :action => 'show' } |
|
98 | 98 | format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} } |
|
99 | 99 | end |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | private |
|
103 | 103 | def find_project |
|
104 | 104 | @project = Project.find(params[:project_id]) |
|
105 | 105 | rescue ActiveRecord::RecordNotFound |
|
106 | 106 | render_404 |
|
107 | 107 | end |
|
108 | 108 | end |
General Comments 0
You need to be logged in to leave comments.
Login now