Files
nairobi/lib/tasks/proposals.rake
taitus 95f848f021 Fix specs after rebase with translations branch
- Fix spec spec/features/management/proposals_spec.rb:24 adding single quotes.
- Remove spec related with 'proposal improvement info link' as master branch.
- Fix proposal rake task (now proposals have translations). We put the 'validate: false' to keep the existing html tags in the  proposal's description. Without the sanitizable module deleting them.
2019-06-27 09:19:37 +02:00

28 lines
855 B
Ruby

namespace :proposals do
desc "Move external_url to description"
task move_external_url_to_description: :environment do
include ActionView::Helpers::SanitizeHelper
include TextWithLinksHelper
models = [Proposal, Legislation::Proposal]
models.each do |model|
print "Move external_url to description for #{model}s"
model.find_each do |resource|
if resource.external_url.present?
Globalize.with_locale(I18n.default_locale) do
new_description = "#{resource.description} <p>#{text_with_links(resource.external_url)}</p>"
resource.description = new_description
resource.external_url = ""
resource.updated_at = Time.current
resource.save(validate: false)
print "."
end
end
end
puts ""
end
end
end