@@ -1,163 +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 = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on |
|
|
40 | @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") | |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | def export_pdf |
|
44 | 44 | @custom_values = @issue.custom_values.find(:all, :include => :custom_field) |
|
45 | 45 | @options_for_rfpdf ||= {} |
|
46 | 46 | @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.id}.pdf" |
|
47 | 47 | end |
|
48 | 48 | |
|
49 | 49 | def edit |
|
50 | 50 | @priorities = Enumeration::get_values('IPRI') |
|
51 | 51 | if request.get? |
|
52 | 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) } |
|
53 | 53 | else |
|
54 | 54 | begin |
|
55 | 55 | @issue.init_journal(self.logged_in_user) |
|
56 | 56 | # Retrieve custom fields and values |
|
57 | 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]) } |
|
58 | 58 | @issue.custom_values = @custom_values |
|
59 | 59 | @issue.attributes = params[:issue] |
|
60 | 60 | if @issue.save |
|
61 | 61 | flash[:notice] = l(:notice_successful_update) |
|
62 | 62 | redirect_to :action => 'show', :id => @issue |
|
63 | 63 | end |
|
64 | 64 | rescue ActiveRecord::StaleObjectError |
|
65 | 65 | # Optimistic locking exception |
|
66 | 66 | flash[:error] = l(:notice_locking_conflict) |
|
67 | 67 | end |
|
68 | 68 | end |
|
69 | 69 | end |
|
70 | 70 | |
|
71 | 71 | def add_note |
|
72 | 72 | unless params[:notes].empty? |
|
73 | 73 | journal = @issue.init_journal(self.logged_in_user, params[:notes]) |
|
74 | 74 | if @issue.save |
|
75 | 75 | flash[:notice] = l(:notice_successful_update) |
|
76 | 76 | Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
77 | 77 | redirect_to :action => 'show', :id => @issue |
|
78 | 78 | return |
|
79 | 79 | end |
|
80 | 80 | end |
|
81 | 81 | show |
|
82 | 82 | render :action => 'show' |
|
83 | 83 | end |
|
84 | 84 | |
|
85 | 85 | def change_status |
|
86 | 86 | @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user |
|
87 | 87 | @new_status = IssueStatus.find(params[:new_status_id]) |
|
88 | 88 | if params[:confirm] |
|
89 | 89 | begin |
|
90 | 90 | journal = @issue.init_journal(self.logged_in_user, params[:notes]) |
|
91 | 91 | @issue.status = @new_status |
|
92 | 92 | if @issue.update_attributes(params[:issue]) |
|
93 | 93 | # Save attachments |
|
94 | 94 | params[:attachments].each { |file| |
|
95 | 95 | next unless file.size > 0 |
|
96 | 96 | a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user) |
|
97 | 97 | journal.details << JournalDetail.new(:property => 'attachment', |
|
98 | 98 | :prop_key => a.id, |
|
99 | 99 | :value => a.filename) unless a.new_record? |
|
100 | 100 | } if params[:attachments] and params[:attachments].is_a? Array |
|
101 | 101 | |
|
102 | 102 | # Log time |
|
103 | 103 | if logged_in_user.authorized_to(@project, "timelog/edit") |
|
104 | 104 | @time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => logged_in_user, :spent_on => Date.today) |
|
105 | 105 | @time_entry.attributes = params[:time_entry] |
|
106 | 106 | @time_entry.save |
|
107 | 107 | end |
|
108 | 108 | |
|
109 | 109 | flash[:notice] = l(:notice_successful_update) |
|
110 | 110 | Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
111 | 111 | redirect_to :action => 'show', :id => @issue |
|
112 | 112 | end |
|
113 | 113 | rescue ActiveRecord::StaleObjectError |
|
114 | 114 | # Optimistic locking exception |
|
115 | 115 | flash[:error] = l(:notice_locking_conflict) |
|
116 | 116 | end |
|
117 | 117 | end |
|
118 | 118 | @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user } |
|
119 | 119 | @activities = Enumeration::get_values('ACTI') |
|
120 | 120 | end |
|
121 | 121 | |
|
122 | 122 | def destroy |
|
123 | 123 | @issue.destroy |
|
124 | 124 | redirect_to :controller => 'projects', :action => 'list_issues', :id => @project |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | def add_attachment |
|
128 | 128 | # Save the attachments |
|
129 | 129 | @attachments = [] |
|
130 | 130 | journal = @issue.init_journal(self.logged_in_user) |
|
131 | 131 | params[:attachments].each { |file| |
|
132 | 132 | next unless file.size > 0 |
|
133 | 133 | a = Attachment.create(:container => @issue, :file => file, :author => logged_in_user) |
|
134 | 134 | @attachments << a unless a.new_record? |
|
135 | 135 | journal.details << JournalDetail.new(:property => 'attachment', |
|
136 | 136 | :prop_key => a.id, |
|
137 | 137 | :value => a.filename) unless a.new_record? |
|
138 | 138 | } if params[:attachments] and params[:attachments].is_a? Array |
|
139 | 139 | journal.save if journal.details.any? |
|
140 | 140 | Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
141 | 141 | redirect_to :action => 'show', :id => @issue |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | def destroy_attachment |
|
145 | 145 | a = @issue.attachments.find(params[:attachment_id]) |
|
146 | 146 | a.destroy |
|
147 | 147 | journal = @issue.init_journal(self.logged_in_user) |
|
148 | 148 | journal.details << JournalDetail.new(:property => 'attachment', |
|
149 | 149 | :prop_key => a.id, |
|
150 | 150 | :old_value => a.filename) |
|
151 | 151 | journal.save |
|
152 | 152 | redirect_to :action => 'show', :id => @issue |
|
153 | 153 | end |
|
154 | 154 | |
|
155 | 155 | private |
|
156 | 156 | def find_project |
|
157 | 157 | @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) |
|
158 | 158 | @project = @issue.project |
|
159 | 159 | @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}" |
|
160 | 160 | rescue ActiveRecord::RecordNotFound |
|
161 | 161 | render_404 |
|
162 | 162 | end |
|
163 | 163 | end |
@@ -1,13 +1,13 | |||
|
1 |
<% note_id = |
|
|
1 | <% note_id = 1 %> | |
|
2 | 2 | <% for journal in journals %> |
|
3 | 3 | <h4><div style="float:right;"><%= link_to "##{note_id}", :anchor => "note-#{note_id}" %></div> |
|
4 | 4 | <%= content_tag('a', '', :name => "note-#{note_id}")%> |
|
5 | 5 | <%= format_time(journal.created_on) %> - <%= journal.user.name %></h4> |
|
6 | 6 | <ul> |
|
7 | 7 | <% for detail in journal.details %> |
|
8 | 8 | <li><%= show_detail(detail) %></li> |
|
9 | 9 | <% end %> |
|
10 | 10 | </ul> |
|
11 | 11 | <%= textilizable(journal.notes) unless journal.notes.blank? %> |
|
12 |
<% note_id |
|
|
12 | <% note_id += 1 %> | |
|
13 | 13 | <% end %> |
General Comments 0
You need to be logged in to leave comments.
Login now