@@ -1,145 +1,145 | |||
|
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 IssuesController < ApplicationController |
|
19 | 19 | layout 'base', :except => :export_pdf |
|
20 | 20 | before_filter :find_project, :authorize |
|
21 | 21 | |
|
22 | 22 | helper :custom_fields |
|
23 | 23 | include CustomFieldsHelper |
|
24 | 24 | helper :ifpdf |
|
25 | 25 | include IfpdfHelper |
|
26 | 26 | |
|
27 | 27 | def show |
|
28 | 28 | @status_options = @issue.status.workflows.find(:all, :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user |
|
29 | 29 | @custom_values = @issue.custom_values.find(:all, :include => :custom_field) |
|
30 | 30 | @journals_count = @issue.journals.count |
|
31 | 31 | @journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "journals.created_on desc") |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def history |
|
35 | 35 | @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "journals.created_on desc") |
|
36 | 36 | @journals_count = @journals.length |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def export_pdf |
|
40 | 40 | @custom_values = @issue.custom_values.find(:all, :include => :custom_field) |
|
41 | 41 | @options_for_rfpdf ||= {} |
|
42 | 42 | @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf" |
|
43 | 43 | end |
|
44 | 44 | |
|
45 | 45 | def edit |
|
46 | 46 | @priorities = Enumeration::get_values('IPRI') |
|
47 | 47 | if request.get? |
|
48 | 48 | @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) } |
|
49 | 49 | else |
|
50 | 50 | begin |
|
51 | 51 | @issue.init_journal(self.logged_in_user) |
|
52 | 52 | # Retrieve custom fields and values |
|
53 | 53 | @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]) } |
|
54 | 54 | @issue.custom_values = @custom_values |
|
55 | 55 | @issue.attributes = params[:issue] |
|
56 | 56 | if @issue.save |
|
57 | 57 | flash[:notice] = l(:notice_successful_update) |
|
58 | 58 | redirect_to :action => 'show', :id => @issue |
|
59 | 59 | end |
|
60 | 60 | rescue ActiveRecord::StaleObjectError |
|
61 | 61 | # Optimistic locking exception |
|
62 | 62 | flash[:notice] = l(:notice_locking_conflict) |
|
63 | 63 | end |
|
64 | 64 | end |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | def add_note |
|
68 | 68 | unless params[:notes].empty? |
|
69 | 69 | journal = @issue.init_journal(self.logged_in_user, params[:notes]) |
|
70 | 70 | #@history = @issue.histories.build(params[:history]) |
|
71 | 71 | #@history.author_id = self.logged_in_user.id if self.logged_in_user |
|
72 | 72 | #@history.status = @issue.status |
|
73 | 73 | if @issue.save |
|
74 | 74 | flash[:notice] = l(:notice_successful_update) |
|
75 | 75 | Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled? |
|
76 | 76 | redirect_to :action => 'show', :id => @issue |
|
77 | 77 | return |
|
78 | 78 | end |
|
79 | 79 | end |
|
80 | 80 | show |
|
81 | 81 | render :action => 'show' |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | def change_status |
|
85 | 85 | #@history = @issue.histories.build(params[:history]) |
|
86 | 86 | @status_options = @issue.status.workflows.find(:all, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user |
|
87 | 87 | @new_status = IssueStatus.find(params[:new_status_id]) |
|
88 | 88 | if params[:confirm] |
|
89 | 89 | begin |
|
90 | 90 | #@history.author_id = self.logged_in_user.id if self.logged_in_user |
|
91 | 91 | #@issue.status = @history.status |
|
92 | 92 | #@issue.fixed_version_id = (params[:issue][:fixed_version_id]) |
|
93 | 93 | #@issue.assigned_to_id = (params[:issue][:assigned_to_id]) |
|
94 | 94 | #@issue.done_ratio = (params[:issue][:done_ratio]) |
|
95 | 95 | #@issue.lock_version = (params[:issue][:lock_version]) |
|
96 | @issue.init_journal(self.logged_in_user, params[:notes]) | |
|
96 | journal = @issue.init_journal(self.logged_in_user, params[:notes]) | |
|
97 | 97 | @issue.status = @new_status |
|
98 | 98 | if @issue.update_attributes(params[:issue]) |
|
99 | 99 | flash[:notice] = l(:notice_successful_update) |
|
100 |
Mailer.deliver_issue_ |
|
|
100 | Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled? | |
|
101 | 101 | redirect_to :action => 'show', :id => @issue |
|
102 | 102 | end |
|
103 | 103 | rescue ActiveRecord::StaleObjectError |
|
104 | 104 | # Optimistic locking exception |
|
105 | 105 | flash[:notice] = l(:notice_locking_conflict) |
|
106 | 106 | end |
|
107 | 107 | end |
|
108 | 108 | @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user } |
|
109 | 109 | end |
|
110 | 110 | |
|
111 | 111 | def destroy |
|
112 | 112 | @issue.destroy |
|
113 | 113 | redirect_to :controller => 'projects', :action => 'list_issues', :id => @project |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | 116 | def add_attachment |
|
117 | 117 | # Save the attachments |
|
118 | 118 | params[:attachments].each { |a| |
|
119 | 119 | @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0 |
|
120 | 120 | @attachment.save |
|
121 | 121 | } if params[:attachments] and params[:attachments].is_a? Array |
|
122 | 122 | redirect_to :action => 'show', :id => @issue |
|
123 | 123 | end |
|
124 | 124 | |
|
125 | 125 | def destroy_attachment |
|
126 | 126 | @issue.attachments.find(params[:attachment_id]).destroy |
|
127 | 127 | redirect_to :action => 'show', :id => @issue |
|
128 | 128 | end |
|
129 | 129 | |
|
130 | 130 | # Send the file in stream mode |
|
131 | 131 | def download |
|
132 | 132 | @attachment = @issue.attachments.find(params[:attachment_id]) |
|
133 | 133 | send_file @attachment.diskfile, :filename => @attachment.filename |
|
134 | 134 | rescue |
|
135 | 135 | flash.now[:notice] = l(:notice_file_not_found) |
|
136 | 136 | render :text => "", :layout => true, :status => 404 |
|
137 | 137 | end |
|
138 | 138 | |
|
139 | 139 | private |
|
140 | 140 | def find_project |
|
141 | 141 | @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) |
|
142 | 142 | @project = @issue.project |
|
143 | 143 | @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}" |
|
144 | 144 | end |
|
145 | 145 | end |
@@ -1,51 +1,53 | |||
|
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 | class Mailer < ActionMailer::Base | |
|
18 | class Mailer < ActionMailer::Base | |
|
19 | ||
|
20 | helper IssuesHelper | |
|
19 | 21 | |
|
20 | 22 | def issue_add(issue) |
|
21 | 23 | # Sends to all project members |
|
22 | 24 | @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification } |
|
23 | 25 | @from = $RDM_MAIL_FROM |
|
24 | 26 | @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" |
|
25 | 27 | @body['issue'] = issue |
|
26 | 28 | end |
|
27 | 29 | |
|
28 | 30 | def issue_edit(journal) |
|
29 | 31 | # Sends to all project members |
|
30 | 32 | issue = journal.journalized |
|
31 | 33 | @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification } |
|
32 | 34 | @from = $RDM_MAIL_FROM |
|
33 | 35 | @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" |
|
34 | 36 | @body['issue'] = issue |
|
35 | 37 | @body['journal']= journal |
|
36 | 38 | end |
|
37 | 39 | |
|
38 | 40 | def lost_password(token) |
|
39 | 41 | @recipients = token.user.mail |
|
40 | 42 | @from = $RDM_MAIL_FROM |
|
41 | 43 | @subject = l(:mail_subject_lost_password) |
|
42 | 44 | @body['token'] = token |
|
43 | 45 | end |
|
44 | 46 | |
|
45 | 47 | def register(token) |
|
46 | 48 | @recipients = token.user.mail |
|
47 | 49 | @from = $RDM_MAIL_FROM |
|
48 | 50 | @subject = l(:mail_subject_register) |
|
49 | 51 | @body['token'] = token |
|
50 | 52 | end |
|
51 | 53 | end |
@@ -1,8 +1,8 | |||
|
1 | 1 | Issue #<%= @issue.id %> has been updated. |
|
2 | 2 | <%= @journal.user.name %> |
|
3 | 3 | <% for detail in @journal.details %> |
|
4 | <%= show_detail(detail) %> | |
|
4 | <%= show_detail(detail, true) %> | |
|
5 | 5 | <% end %> |
|
6 | 6 | <%= @journal.notes if @journal.notes? %> |
|
7 | 7 | ---------------------------------------- |
|
8 | 8 | <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file |
@@ -1,8 +1,8 | |||
|
1 | 1 | Issue #<%= @issue.id %> has been updated. |
|
2 | 2 | <%= @journal.user.name %> |
|
3 | 3 | <% for detail in @journal.details %> |
|
4 | <%= show_detail(detail) %> | |
|
4 | <%= show_detail(detail, true) %> | |
|
5 | 5 | <% end %> |
|
6 | 6 | <%= @journal.notes if @journal.notes? %> |
|
7 | 7 | ---------------------------------------- |
|
8 | 8 | <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file |
@@ -1,8 +1,8 | |||
|
1 | 1 | Issue #<%= @issue.id %> has been updated. |
|
2 | 2 | <%= @journal.user.name %> |
|
3 | 3 | <% for detail in @journal.details %> |
|
4 | <%= show_detail(detail) %> | |
|
4 | <%= show_detail(detail, true) %> | |
|
5 | 5 | <% end %> |
|
6 | 6 | <%= @journal.notes if @journal.notes? %> |
|
7 | 7 | ---------------------------------------- |
|
8 | 8 | <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file |
@@ -1,8 +1,8 | |||
|
1 | 1 | La demande #<%= @issue.id %> a été mise à jour. |
|
2 | 2 | <%= @journal.user.name %> - <%= format_date(@journal.created_on) %> |
|
3 | 3 | <% for detail in @journal.details %> |
|
4 | <%= show_detail(detail) %> | |
|
4 | <%= show_detail(detail, true) %> | |
|
5 | 5 | <% end %> |
|
6 | 6 | <%= journal.notes if journal.notes? %> |
|
7 | 7 | ---------------------------------------- |
|
8 | 8 | <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now