##// END OF EJS Templates
mailer bug fix...
Jean-Philippe Lang -
r53:418b8d861a6b
parent child
Show More
@@ -1,145 +1,145
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class IssuesController < ApplicationController
18 class IssuesController < ApplicationController
19 layout 'base', :except => :export_pdf
19 layout 'base', :except => :export_pdf
20 before_filter :find_project, :authorize
20 before_filter :find_project, :authorize
21
21
22 helper :custom_fields
22 helper :custom_fields
23 include CustomFieldsHelper
23 include CustomFieldsHelper
24 helper :ifpdf
24 helper :ifpdf
25 include IfpdfHelper
25 include IfpdfHelper
26
26
27 def show
27 def show
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
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 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
29 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
30 @journals_count = @issue.journals.count
30 @journals_count = @issue.journals.count
31 @journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "journals.created_on desc")
31 @journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "journals.created_on desc")
32 end
32 end
33
33
34 def history
34 def history
35 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "journals.created_on desc")
35 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "journals.created_on desc")
36 @journals_count = @journals.length
36 @journals_count = @journals.length
37 end
37 end
38
38
39 def export_pdf
39 def export_pdf
40 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
40 @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
41 @options_for_rfpdf ||= {}
41 @options_for_rfpdf ||= {}
42 @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf"
42 @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf"
43 end
43 end
44
44
45 def edit
45 def edit
46 @priorities = Enumeration::get_values('IPRI')
46 @priorities = Enumeration::get_values('IPRI')
47 if request.get?
47 if request.get?
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) }
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 else
49 else
50 begin
50 begin
51 @issue.init_journal(self.logged_in_user)
51 @issue.init_journal(self.logged_in_user)
52 # Retrieve custom fields and values
52 # Retrieve custom fields and values
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]) }
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 @issue.custom_values = @custom_values
54 @issue.custom_values = @custom_values
55 @issue.attributes = params[:issue]
55 @issue.attributes = params[:issue]
56 if @issue.save
56 if @issue.save
57 flash[:notice] = l(:notice_successful_update)
57 flash[:notice] = l(:notice_successful_update)
58 redirect_to :action => 'show', :id => @issue
58 redirect_to :action => 'show', :id => @issue
59 end
59 end
60 rescue ActiveRecord::StaleObjectError
60 rescue ActiveRecord::StaleObjectError
61 # Optimistic locking exception
61 # Optimistic locking exception
62 flash[:notice] = l(:notice_locking_conflict)
62 flash[:notice] = l(:notice_locking_conflict)
63 end
63 end
64 end
64 end
65 end
65 end
66
66
67 def add_note
67 def add_note
68 unless params[:notes].empty?
68 unless params[:notes].empty?
69 journal = @issue.init_journal(self.logged_in_user, params[:notes])
69 journal = @issue.init_journal(self.logged_in_user, params[:notes])
70 #@history = @issue.histories.build(params[:history])
70 #@history = @issue.histories.build(params[:history])
71 #@history.author_id = self.logged_in_user.id if self.logged_in_user
71 #@history.author_id = self.logged_in_user.id if self.logged_in_user
72 #@history.status = @issue.status
72 #@history.status = @issue.status
73 if @issue.save
73 if @issue.save
74 flash[:notice] = l(:notice_successful_update)
74 flash[:notice] = l(:notice_successful_update)
75 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
75 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
76 redirect_to :action => 'show', :id => @issue
76 redirect_to :action => 'show', :id => @issue
77 return
77 return
78 end
78 end
79 end
79 end
80 show
80 show
81 render :action => 'show'
81 render :action => 'show'
82 end
82 end
83
83
84 def change_status
84 def change_status
85 #@history = @issue.histories.build(params[:history])
85 #@history = @issue.histories.build(params[:history])
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
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 @new_status = IssueStatus.find(params[:new_status_id])
87 @new_status = IssueStatus.find(params[:new_status_id])
88 if params[:confirm]
88 if params[:confirm]
89 begin
89 begin
90 #@history.author_id = self.logged_in_user.id if self.logged_in_user
90 #@history.author_id = self.logged_in_user.id if self.logged_in_user
91 #@issue.status = @history.status
91 #@issue.status = @history.status
92 #@issue.fixed_version_id = (params[:issue][:fixed_version_id])
92 #@issue.fixed_version_id = (params[:issue][:fixed_version_id])
93 #@issue.assigned_to_id = (params[:issue][:assigned_to_id])
93 #@issue.assigned_to_id = (params[:issue][:assigned_to_id])
94 #@issue.done_ratio = (params[:issue][:done_ratio])
94 #@issue.done_ratio = (params[:issue][:done_ratio])
95 #@issue.lock_version = (params[:issue][:lock_version])
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 @issue.status = @new_status
97 @issue.status = @new_status
98 if @issue.update_attributes(params[:issue])
98 if @issue.update_attributes(params[:issue])
99 flash[:notice] = l(:notice_successful_update)
99 flash[:notice] = l(:notice_successful_update)
100 Mailer.deliver_issue_change_status(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
100 Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
101 redirect_to :action => 'show', :id => @issue
101 redirect_to :action => 'show', :id => @issue
102 end
102 end
103 rescue ActiveRecord::StaleObjectError
103 rescue ActiveRecord::StaleObjectError
104 # Optimistic locking exception
104 # Optimistic locking exception
105 flash[:notice] = l(:notice_locking_conflict)
105 flash[:notice] = l(:notice_locking_conflict)
106 end
106 end
107 end
107 end
108 @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
108 @assignable_to = @project.members.find(:all, :include => :user).collect{ |m| m.user }
109 end
109 end
110
110
111 def destroy
111 def destroy
112 @issue.destroy
112 @issue.destroy
113 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
113 redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
114 end
114 end
115
115
116 def add_attachment
116 def add_attachment
117 # Save the attachments
117 # Save the attachments
118 params[:attachments].each { |a|
118 params[:attachments].each { |a|
119 @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
119 @attachment = @issue.attachments.build(:file => a, :author => self.logged_in_user) unless a.size == 0
120 @attachment.save
120 @attachment.save
121 } if params[:attachments] and params[:attachments].is_a? Array
121 } if params[:attachments] and params[:attachments].is_a? Array
122 redirect_to :action => 'show', :id => @issue
122 redirect_to :action => 'show', :id => @issue
123 end
123 end
124
124
125 def destroy_attachment
125 def destroy_attachment
126 @issue.attachments.find(params[:attachment_id]).destroy
126 @issue.attachments.find(params[:attachment_id]).destroy
127 redirect_to :action => 'show', :id => @issue
127 redirect_to :action => 'show', :id => @issue
128 end
128 end
129
129
130 # Send the file in stream mode
130 # Send the file in stream mode
131 def download
131 def download
132 @attachment = @issue.attachments.find(params[:attachment_id])
132 @attachment = @issue.attachments.find(params[:attachment_id])
133 send_file @attachment.diskfile, :filename => @attachment.filename
133 send_file @attachment.diskfile, :filename => @attachment.filename
134 rescue
134 rescue
135 flash.now[:notice] = l(:notice_file_not_found)
135 flash.now[:notice] = l(:notice_file_not_found)
136 render :text => "", :layout => true, :status => 404
136 render :text => "", :layout => true, :status => 404
137 end
137 end
138
138
139 private
139 private
140 def find_project
140 def find_project
141 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
141 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
142 @project = @issue.project
142 @project = @issue.project
143 @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
143 @html_title = "#{@project.name} - #{@issue.tracker.name} ##{@issue.id}"
144 end
144 end
145 end
145 end
@@ -1,51 +1,53
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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
19
20 helper IssuesHelper
21
20 def issue_add(issue)
22 def issue_add(issue)
21 # Sends to all project members
23 # Sends to all project members
22 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
24 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
23 @from = $RDM_MAIL_FROM
25 @from = $RDM_MAIL_FROM
24 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
26 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
25 @body['issue'] = issue
27 @body['issue'] = issue
26 end
28 end
27
29
28 def issue_edit(journal)
30 def issue_edit(journal)
29 # Sends to all project members
31 # Sends to all project members
30 issue = journal.journalized
32 issue = journal.journalized
31 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
33 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
32 @from = $RDM_MAIL_FROM
34 @from = $RDM_MAIL_FROM
33 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
35 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
34 @body['issue'] = issue
36 @body['issue'] = issue
35 @body['journal']= journal
37 @body['journal']= journal
36 end
38 end
37
39
38 def lost_password(token)
40 def lost_password(token)
39 @recipients = token.user.mail
41 @recipients = token.user.mail
40 @from = $RDM_MAIL_FROM
42 @from = $RDM_MAIL_FROM
41 @subject = l(:mail_subject_lost_password)
43 @subject = l(:mail_subject_lost_password)
42 @body['token'] = token
44 @body['token'] = token
43 end
45 end
44
46
45 def register(token)
47 def register(token)
46 @recipients = token.user.mail
48 @recipients = token.user.mail
47 @from = $RDM_MAIL_FROM
49 @from = $RDM_MAIL_FROM
48 @subject = l(:mail_subject_register)
50 @subject = l(:mail_subject_register)
49 @body['token'] = token
51 @body['token'] = token
50 end
52 end
51 end
53 end
@@ -1,8 +1,8
1 Issue #<%= @issue.id %> has been updated.
1 Issue #<%= @issue.id %> has been updated.
2 <%= @journal.user.name %>
2 <%= @journal.user.name %>
3 <% for detail in @journal.details %>
3 <% for detail in @journal.details %>
4 <%= show_detail(detail) %>
4 <%= show_detail(detail, true) %>
5 <% end %>
5 <% end %>
6 <%= @journal.notes if @journal.notes? %>
6 <%= @journal.notes if @journal.notes? %>
7 ----------------------------------------
7 ----------------------------------------
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
@@ -1,8 +1,8
1 Issue #<%= @issue.id %> has been updated.
1 Issue #<%= @issue.id %> has been updated.
2 <%= @journal.user.name %>
2 <%= @journal.user.name %>
3 <% for detail in @journal.details %>
3 <% for detail in @journal.details %>
4 <%= show_detail(detail) %>
4 <%= show_detail(detail, true) %>
5 <% end %>
5 <% end %>
6 <%= @journal.notes if @journal.notes? %>
6 <%= @journal.notes if @journal.notes? %>
7 ----------------------------------------
7 ----------------------------------------
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
@@ -1,8 +1,8
1 Issue #<%= @issue.id %> has been updated.
1 Issue #<%= @issue.id %> has been updated.
2 <%= @journal.user.name %>
2 <%= @journal.user.name %>
3 <% for detail in @journal.details %>
3 <% for detail in @journal.details %>
4 <%= show_detail(detail) %>
4 <%= show_detail(detail, true) %>
5 <% end %>
5 <% end %>
6 <%= @journal.notes if @journal.notes? %>
6 <%= @journal.notes if @journal.notes? %>
7 ----------------------------------------
7 ----------------------------------------
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
@@ -1,8 +1,8
1 La demande #<%= @issue.id %> a été mise à jour.
1 La demande #<%= @issue.id %> a été mise à jour.
2 <%= @journal.user.name %> - <%= format_date(@journal.created_on) %>
2 <%= @journal.user.name %> - <%= format_date(@journal.created_on) %>
3 <% for detail in @journal.details %>
3 <% for detail in @journal.details %>
4 <%= show_detail(detail) %>
4 <%= show_detail(detail, true) %>
5 <% end %>
5 <% end %>
6 <%= journal.notes if journal.notes? %>
6 <%= journal.notes if journal.notes? %>
7 ----------------------------------------
7 ----------------------------------------
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %>
General Comments 0
You need to be logged in to leave comments. Login now