##// END OF EJS Templates
Removed IssuesController#history, all changes are now displayed on issues/show (not only the last 15)....
Jean-Philippe Lang -
r610:6862b9790904
parent child
Show More
@@ -1,169 +1,163
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 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 IssuesController < ApplicationController
19 19 layout 'base', :except => :export_pdf
20 20 before_filter :find_project, :authorize
21 21
22 22 cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
23 23
24 24 helper :projects
25 25 include ProjectsHelper
26 26 helper :custom_fields
27 27 include CustomFieldsHelper
28 28 helper :ifpdf
29 29 include IfpdfHelper
30 30 helper :issue_relations
31 31 include IssueRelationsHelper
32 32 helper :watchers
33 33 include WatchersHelper
34 34 helper :attachments
35 35 include AttachmentsHelper
36 36
37 37 def show
38 38 @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
39 39 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
40 @journals_count = @issue.journals.count
41 @journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "#{Journal.table_name}.created_on desc")
42 end
43
44 def history
45 40 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on desc")
46 @journals_count = @journals.length
47 41 end
48 42
49 43 def export_pdf
50 44 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
51 45 @options_for_rfpdf ||= {}
52 46 @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.id}.pdf"
53 47 end
54 48
55 49 def edit
56 50 @priorities = Enumeration::get_values('IPRI')
57 51 if request.get?
58 52 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) }
59 53 else
60 54 begin
61 55 @issue.init_journal(self.logged_in_user)
62 56 # Retrieve custom fields and values
63 57 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
64 58 @issue.custom_values = @custom_values
65 59 @issue.attributes = params[:issue]
66 60 if @issue.save
67 61 flash[:notice] = l(:notice_successful_update)
68 62 redirect_to :action => 'show', :id => @issue
69 63 end
70 64 rescue ActiveRecord::StaleObjectError
71 65 # Optimistic locking exception
72 66 flash[:error] = l(:notice_locking_conflict)
73 67 end
74 68 end
75 69 end
76 70
77 71 def add_note
78 72 unless params[:notes].empty?
79 73 journal = @issue.init_journal(self.logged_in_user, params[:notes])
80 74 if @issue.save
81 75 flash[:notice] = l(:notice_successful_update)
82 76 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
83 77 redirect_to :action => 'show', :id => @issue
84 78 return
85 79 end
86 80 end
87 81 show
88 82 render :action => 'show'
89 83 end
90 84
91 85 def change_status
92 86 @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
93 87 @new_status = IssueStatus.find(params[:new_status_id])
94 88 if params[:confirm]
95 89 begin
96 90 journal = @issue.init_journal(self.logged_in_user, params[:notes])
97 91 @issue.status = @new_status
98 92 if @issue.update_attributes(params[:issue])
99 93 # Save attachments
100 94 params[:attachments].each { |file|
101 95 next unless file.size > 0
102 96 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
103 97 journal.details << JournalDetail.new(:property => 'attachment',
104 98 :prop_key => a.id,
105 99 :value => a.filename) unless a.new_record?
106 100 } if params[:attachments] and params[:attachments].is_a? Array
107 101
108 102 # Log time
109 103 if logged_in_user.authorized_to(@project, "timelog/edit")
110 104 @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => logged_in_user, :spent_on => Date.today)
111 105 @time_entry.attributes = params[:time_entry]
112 106 @time_entry.save
113 107 end
114 108
115 109 flash[:notice] = l(:notice_successful_update)
116 110 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
117 111 redirect_to :action => 'show', :id => @issue
118 112 end
119 113 rescue ActiveRecord::StaleObjectError
120 114 # Optimistic locking exception
121 115 flash[:error] = l(:notice_locking_conflict)
122 116 end
123 117 end
124 118 @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
125 119 @activities = Enumeration::get_values('ACTI')
126 120 end
127 121
128 122 def destroy
129 123 @issue.destroy
130 124 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
131 125 end
132 126
133 127 def add_attachment
134 128 # Save the attachments
135 129 @attachments = []
136 130 journal = @issue.init_journal(self.logged_in_user)
137 131 params[:attachments].each { |file|
138 132 next unless file.size > 0
139 133 a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user)
140 134 @attachments << a unless a.new_record?
141 135 journal.details << JournalDetail.new(:property => 'attachment',
142 136 :prop_key => a.id,
143 137 :value => a.filename) unless a.new_record?
144 138 } if params[:attachments] and params[:attachments].is_a? Array
145 139 journal.save if journal.details.any?
146 140 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
147 141 redirect_to :action => 'show', :id => @issue
148 142 end
149 143
150 144 def destroy_attachment
151 145 a = @issue.attachments.find(params[:attachment_id])
152 146 a.destroy
153 147 journal = @issue.init_journal(self.logged_in_user)
154 148 journal.details << JournalDetail.new(:property => 'attachment',
155 149 :prop_key => a.id,
156 150 :old_value => a.filename)
157 151 journal.save
158 152 redirect_to :action => 'show', :id => @issue
159 153 end
160 154
161 155 private
162 156 def find_project
163 157 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
164 158 @project = @issue.project
165 159 @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
166 160 rescue ActiveRecord::RecordNotFound
167 161 render_404
168 162 end
169 163 end
@@ -1,11 +1,13
1 <% note_id = journals.length %>
1 2 <% for journal in journals %>
2 <h4><%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
3 <h4><div style="float:right;"><%= link_to "##{note_id}", :anchor => "note-#{note_id}" %></div>
4 <%= content_tag('a', '', :name => "note-#{note_id}")%>
5 <%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
3 6 <ul>
4 7 <% for detail in journal.details %>
5 8 <li><%= show_detail(detail) %></li>
6 9 <% end %>
7 10 </ul>
8 <% if journal.notes? %>
9 <%= textilizable(journal.notes) %>
10 <% end %>
11 <%= textilizable(journal.notes) unless journal.notes.blank? %>
12 <% note_id -= 1 %>
11 13 <% end %>
@@ -1,118 +1,114
1 1 <div class="contextual">
2 2 <%= l(:label_export_to) %><%= link_to 'PDF', {:action => 'export_pdf', :id => @issue}, :class => 'icon icon-pdf' %>
3 3 </div>
4 4
5 5 <h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %></h2>
6 6
7 7 <div class="box">
8 8 <table width="100%">
9 9 <tr>
10 10 <td style="width:15%"><b><%=l(:field_status)%> :</b></td><td style="width:35%"><%= @issue.status.name %></td>
11 11 <td style="width:15%"><b><%=l(:field_priority)%> :</b></td><td style="width:35%"><%= @issue.priority.name %></td>
12 12 </tr>
13 13 <tr>
14 14 <td><b><%=l(:field_assigned_to)%> :</b></td><td><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
15 15 <td><b><%=l(:field_category)%> :</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td>
16 16 </tr>
17 17 <tr>
18 18 <td><b><%=l(:field_author)%> :</b></td><td><%= link_to_user @issue.author %></td>
19 19 <td><b><%=l(:field_start_date)%> :</b></td><td><%= format_date(@issue.start_date) %></td>
20 20 </tr>
21 21 <tr>
22 22 <td><b><%=l(:field_created_on)%> :</b></td><td><%= format_date(@issue.created_on) %></td>
23 23 <td><b><%=l(:field_due_date)%> :</b></td><td><%= format_date(@issue.due_date) %></td>
24 24 </tr>
25 25 <tr>
26 26 <td><b><%=l(:field_updated_on)%> :</b></td><td><%= format_date(@issue.updated_on) %></td>
27 27 <td><b><%=l(:field_done_ratio)%> :</b></td><td><%= @issue.done_ratio %> %</td>
28 28 </tr>
29 29 <tr>
30 30 <td><b><%=l(:field_fixed_version)%> :</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
31 31 <td><b><%=l(:label_spent_time)%> :</b></td>
32 32 <td><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :issue_id => @issue}, :class => 'icon icon-time') : "-" %></td>
33 33 </tr>
34 34 <tr>
35 35 <% n = 0
36 36 for custom_value in @custom_values %>
37 37 <td valign="top"><b><%= custom_value.custom_field.name %> :</b></td><td valign="top"><%= simple_format(h(show_value(custom_value))) %></td>
38 38 <% n = n + 1
39 39 if (n > 1)
40 40 n = 0 %>
41 41 </tr><tr>
42 42 <%end
43 43 end %>
44 44 </tr>
45 45 </table>
46 46 <hr />
47 47
48 48 <% if @issue.changesets.any? %>
49 49 <div style="float:right;">
50 50 <em><%= l(:label_revision_plural) %>: <%= @issue.changesets.collect{|changeset| link_to(changeset.revision, :controller => 'repositories', :action => 'revision', :id => @project, :rev => changeset.revision)}.join(", ") %></em>
51 51 </div>
52 52 <% end %>
53 53
54 54 <b><%=l(:field_description)%> :</b><br /><br />
55 55 <%= textilizable @issue.description, :attachments => @issue.attachments %>
56 56 <br />
57 57
58 58 <div class="contextual">
59 59 <%= link_to_if_authorized l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon icon-edit' %>
60 60 <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %>
61 61 <%= watcher_tag(@issue, @logged_in_user) %>
62 62 <%= link_to_if_authorized l(:button_move), {:controller => 'projects', :action => 'move_issues', :id => @project, "issue_ids[]" => @issue.id }, :class => 'icon icon-move' %>
63 63 <%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
64 64 </div>
65 65
66 66 <% if authorize_for('issues', 'change_status') and @status_options and !@status_options.empty? %>
67 67 <% form_tag({:controller => 'issues', :action => 'change_status', :id => @issue}) do %>
68 68 <%=l(:label_change_status)%> :
69 69 <select name="new_status_id">
70 70 <%= options_from_collection_for_select @status_options, "id", "name" %>
71 71 </select>
72 72 <%= submit_tag l(:button_change) %>
73 73 <% end %>
74 74 <% end %>
75 75 &nbsp;
76 76 </div>
77 77
78 78 <% if authorize_for('issue_relations', 'new') || @issue.relations.any? %>
79 79 <div id="relations" class="box">
80 80 <%= render :partial => 'relations' %>
81 81 </div>
82 82 <% end %>
83 83
84 <% if @journals_count > 0 %>
84 <% if @journals.any? %>
85 85 <div id="history" class="box">
86 <h3><%=l(:label_history)%>
87 <% if @journals_count > @journals.length %>(<%= l(:label_last_changes, @journals.length) %>)<% end %></h3>
86 <h3><%=l(:label_history)%></h3>
88 87 <%= render :partial => 'history', :locals => { :journals => @journals } %>
89 <% if @journals_count > @journals.length %>
90 <p><center><small><%= link_to l(:label_change_view_all), :action => 'history', :id => @issue %></small></center></p>
91 <% end %>
92 88 </div>
93 89 <% end %>
94 90
95 91 <div class="box">
96 92 <h3><%=l(:label_attachment_plural)%></h3>
97 93 <%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %>
98 94
99 95 <% if authorize_for('issues', 'add_attachment') %>
100 96 <p><%= toggle_link l(:label_attachment_new), "add_attachment_form" %></p>
101 97 <% form_tag({ :controller => 'issues', :action => 'add_attachment', :id => @issue }, :multipart => true, :class => "tabular", :id => "add_attachment_form", :style => "display:none;") do %>
102 98 <%= render :partial => 'attachments/form' %>
103 99 <%= submit_tag l(:button_add) %>
104 100 <% end %>
105 101 <% end %>
106 102 </div>
107 103
108 104 <% if authorize_for('issues', 'add_note') %>
109 105 <div class="box">
110 106 <h3><%= l(:label_add_note) %></h3>
111 107 <% form_tag({:controller => 'issues', :action => 'add_note', :id => @issue}, :class => "tabular" ) do %>
112 108 <p><label for="notes"><%=l(:field_notes)%></label>
113 109 <%= text_area_tag 'notes', '', :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
114 110 <%= wikitoolbar_for 'notes' %>
115 111 <%= submit_tag l(:button_add) %>
116 112 <% end %>
117 113 </div>
118 114 <% end %>
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now