mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Allows setting the private flag via mail keyword (#31324).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@18150 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ae24985e03
commit
143c359d90
@ -203,7 +203,9 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
issue.description = cleaned_up_text_body
|
issue.description = cleaned_up_text_body
|
||||||
issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
|
issue.start_date ||= User.current.today if Setting.default_issue_start_date_to_creation_date?
|
||||||
issue.is_private = (handler_options[:issue][:is_private] == '1')
|
if handler_options[:issue][:is_private] == '1'
|
||||||
|
issue.is_private = true
|
||||||
|
end
|
||||||
|
|
||||||
# add To and Cc as watchers before saving so the watchers can reply to Redmine
|
# add To and Cc as watchers before saving so the watchers can reply to Redmine
|
||||||
add_watchers(issue)
|
add_watchers(issue)
|
||||||
@ -415,12 +417,38 @@ class MailHandler < ActionMailer::Base
|
|||||||
'due_date' => get_keyword(:due_date, :format => '\d{4}-\d{2}-\d{2}'),
|
'due_date' => get_keyword(:due_date, :format => '\d{4}-\d{2}-\d{2}'),
|
||||||
'estimated_hours' => get_keyword(:estimated_hours),
|
'estimated_hours' => get_keyword(:estimated_hours),
|
||||||
'done_ratio' => get_keyword(:done_ratio, :format => '(\d|10)?0'),
|
'done_ratio' => get_keyword(:done_ratio, :format => '(\d|10)?0'),
|
||||||
|
'is_private' => get_keyword_bool(:is_private),
|
||||||
'parent_issue_id' => get_keyword(:parent_issue)
|
'parent_issue_id' => get_keyword(:parent_issue)
|
||||||
}.delete_if {|k, v| v.blank? }
|
}.delete_if {|k, v| v.blank? }
|
||||||
|
|
||||||
attrs
|
attrs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_keyword_bool(attr)
|
||||||
|
true_values = ["1"]
|
||||||
|
false_values = ["0"]
|
||||||
|
locales = [Setting.default_language]
|
||||||
|
if user
|
||||||
|
locales << user.language
|
||||||
|
end
|
||||||
|
locales.select(&:present?).each do |locale|
|
||||||
|
true_values << l("general_text_yes", :default => '', :locale => locale)
|
||||||
|
true_values << l("general_text_Yes", :default => '', :locale => locale)
|
||||||
|
false_values << l("general_text_no", :default => '', :locale => locale)
|
||||||
|
false_values << l("general_text_No", :default => '', :locale => locale)
|
||||||
|
end
|
||||||
|
values = (true_values + false_values).select(&:present?)
|
||||||
|
format = Regexp.union values
|
||||||
|
if value = get_keyword(attr, :format => format)
|
||||||
|
if true_values.include?(value)
|
||||||
|
return true
|
||||||
|
elsif false_values.include?(value)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
# Returns a Hash of issue custom field values extracted from keywords in the email body
|
# Returns a Hash of issue custom field values extracted from keywords in the email body
|
||||||
def custom_field_values_from_keywords(customized)
|
def custom_field_values_from_keywords(customized)
|
||||||
customized.custom_field_values.inject({}) do |h, v|
|
customized.custom_field_values.inject({}) do |h, v|
|
||||||
|
|||||||
41
test/fixtures/mail_handler/ticket_with_localized_private_flag.eml
vendored
Normal file
41
test/fixtures/mail_handler/ticket_with_localized_private_flag.eml
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
Return-Path: <jsmith@somenet.foo>
|
||||||
|
Received: from osiris ([127.0.0.1])
|
||||||
|
by OSIRIS
|
||||||
|
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||||
|
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||||
|
From: "John Smith" <jsmith@somenet.foo>
|
||||||
|
To: <redmine@somenet.foo>
|
||||||
|
Subject: New ticket on a given project
|
||||||
|
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain;
|
||||||
|
format=flowed;
|
||||||
|
charset="iso-8859-1";
|
||||||
|
reply-type=original
|
||||||
|
Content-Transfer-Encoding: 7bit
|
||||||
|
X-Priority: 3
|
||||||
|
X-MSMail-Priority: Normal
|
||||||
|
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||||
|
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||||
|
|
||||||
|
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
||||||
|
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
||||||
|
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
||||||
|
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
||||||
|
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
||||||
|
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
||||||
|
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
||||||
|
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
||||||
|
sed, mauris. Pellentesque habitant morbi tristique senectus et netus et
|
||||||
|
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
||||||
|
platea dictumst.
|
||||||
|
|
||||||
|
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
||||||
|
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
||||||
|
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
||||||
|
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
||||||
|
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
||||||
|
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||||
|
|
||||||
|
Projet: onlinestore
|
||||||
|
Privée: oui
|
||||||
@ -496,6 +496,21 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||||||
assert_equal 'ecookbook', issue.project.identifier
|
assert_equal 'ecookbook', issue.project.identifier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_add_issue_with_private_keyword
|
||||||
|
User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr'
|
||||||
|
# give the user permission to set issues private:
|
||||||
|
MemberRole.create! member_id: 3, role_id: 1
|
||||||
|
issue = submit_email(
|
||||||
|
'ticket_with_localized_private_flag.eml',
|
||||||
|
:allow_override => 'is_private,tracker,category,priority'
|
||||||
|
)
|
||||||
|
assert issue.is_a?(Issue)
|
||||||
|
refute issue.new_record?
|
||||||
|
issue.reload
|
||||||
|
assert_equal 'New ticket on a given project', issue.subject
|
||||||
|
assert issue.is_private
|
||||||
|
end
|
||||||
|
|
||||||
def test_add_issue_with_localized_attributes
|
def test_add_issue_with_localized_attributes
|
||||||
User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr'
|
User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr'
|
||||||
issue = submit_email(
|
issue = submit_email(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user