[Fix #1729] Clean mail templates with <code> tags
This commit is contained in:
parent
acc68bc050
commit
20fd7e52e6
2 changed files with 49 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
|||
namespace :'2018_03_29_remove_code_tags_from_mail_templates' do
|
||||
task clean: :environment do
|
||||
remove_code_tag_from_body(Mails::ClosedMail)
|
||||
remove_code_tag_from_body(Mails::InitiatedMail)
|
||||
remove_code_tag_from_body(Mails::ReceivedMail)
|
||||
remove_code_tag_from_body(Mails::RefusedMail)
|
||||
remove_code_tag_from_body(Mails::WithoutContinuationMail)
|
||||
end
|
||||
|
||||
def remove_code_tag_from_body(model_class)
|
||||
mails = model_class.where("body LIKE ?", "%<code>%")
|
||||
puts "#{mails.count} #{model_class.name} to clean"
|
||||
mails.each do |m|
|
||||
puts "cleaning #{model_class.name} ##{m.id}"
|
||||
m.update(body: m.body.gsub("<code>", "").gsub("</code>", ""))
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue