##// END OF EJS Templates
Merged r3865 and r3866 from trunk....
Jean-Philippe Lang -
r3754:a84920ca7016 0.9-stable
parent child
Show More
@@ -1,78 +1,81
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 before_filter :find_version, :except => :close_completed
21 21 before_filter :find_project, :only => :close_completed
22 22 before_filter :authorize
23 23
24 24 helper :custom_fields
25 25 helper :projects
26 26
27 27 def show
28 @issues = @version.fixed_issues.visible.find(:all,
29 :include => [:status, :tracker, :priority],
30 :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id")
28 31 end
29 32
30 33 def edit
31 34 if request.post? && params[:version]
32 35 attributes = params[:version].dup
33 36 attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
34 37 if @version.update_attributes(attributes)
35 38 flash[:notice] = l(:notice_successful_update)
36 39 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
37 40 end
38 41 end
39 42 end
40 43
41 44 def close_completed
42 45 if request.post?
43 46 @project.close_completed_versions
44 47 end
45 48 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
46 49 end
47 50
48 51 def destroy
49 52 if @version.fixed_issues.empty?
50 53 @version.destroy
51 54 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
52 55 else
53 56 flash[:error] = l(:notice_unable_delete_version)
54 57 redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
55 58 end
56 59 end
57 60
58 61 def status_by
59 62 respond_to do |format|
60 63 format.html { render :action => 'show' }
61 64 format.js { render(:update) {|page| page.replace_html 'status_by', render_issue_status_by(@version, params[:status_by])} }
62 65 end
63 66 end
64 67
65 68 private
66 69 def find_version
67 70 @version = Version.find(params[:id])
68 71 @project = @version.project
69 72 rescue ActiveRecord::RecordNotFound
70 73 render_404
71 74 end
72 75
73 76 def find_project
74 77 @project = Project.find(params[:project_id])
75 78 rescue ActiveRecord::RecordNotFound
76 79 render_404
77 80 end
78 81 end
@@ -1,51 +1,48
1 1 <div class="contextual">
2 2 <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %>
3 3 <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %>
4 4 </div>
5 5
6 6 <h2><%= h(@version.name) %></h2>
7 7
8 8 <div id="version-summary">
9 9 <% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %>
10 10 <fieldset><legend><%= l(:label_time_tracking) %></legend>
11 11 <table>
12 12 <tr>
13 13 <td width="130px" align="right"><%= l(:field_estimated_hours) %></td>
14 14 <td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(l_hours(@version.estimated_hours)) %></td>
15 15 </tr>
16 16 <% if User.current.allowed_to?(:view_time_entries, @project) %>
17 17 <tr>
18 18 <td width="130px" align="right"><%= l(:label_spent_time) %></td>
19 19 <td width="240px" class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td>
20 20 </tr>
21 21 <% end %>
22 22 </table>
23 23 </fieldset>
24 24 <% end %>
25 25
26 26 <div id="status_by">
27 27 <%= render_issue_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %>
28 28 </div>
29 29 </div>
30 30
31 31 <div id="roadmap">
32 32 <%= render :partial => 'versions/overview', :locals => {:version => @version} %>
33 33 <%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %>
34 34
35 <% issues = @version.fixed_issues.find(:all,
36 :include => [:status, :tracker, :priority],
37 :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") %>
38 <% if issues.size > 0 %>
35 <% if @issues.present? %>
39 36 <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
40 37 <ul>
41 <% issues.each do |issue| -%>
38 <% @issues.each do |issue| -%>
42 39 <li><%= link_to_issue(issue) %></li>
43 40 <% end -%>
44 41 </ul>
45 42 </fieldset>
46 43 <% end %>
47 44 </div>
48 45
49 46 <%= call_hook :view_versions_show_bottom, :version => @version %>
50 47
51 48 <% html_title @version.name %>
General Comments 0
You need to be logged in to leave comments. Login now