2018-09-13 18:20:01 +02:00
|
|
|
namespace :after_party do
|
|
|
|
desc 'Deployment task: add_path_to_procedures'
|
|
|
|
task add_path_to_procedures: :environment do
|
|
|
|
puts "Running deploy task 'add_path_to_procedures'"
|
|
|
|
|
2018-09-18 18:26:43 +02:00
|
|
|
def print_procedure(procedure)
|
|
|
|
puts "#{procedure.id}##{procedure.path} - #{procedure.errors.full_messages}"
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "Démarches publiées :"
|
2018-09-13 18:20:01 +02:00
|
|
|
Procedure.publiees.where(path: nil).find_each do |procedure|
|
|
|
|
procedure.path = procedure.path
|
2018-09-18 18:26:43 +02:00
|
|
|
if !procedure.save
|
|
|
|
print_procedure(procedure)
|
|
|
|
end
|
2018-09-13 18:20:01 +02:00
|
|
|
end
|
|
|
|
|
2018-09-18 18:26:43 +02:00
|
|
|
puts "Démarches archivées :"
|
2018-09-13 18:20:01 +02:00
|
|
|
Procedure.archivees.where(path: nil).find_each do |procedure|
|
2018-09-18 18:26:43 +02:00
|
|
|
if procedure.procedure_path.present?
|
|
|
|
procedure.path = procedure.path
|
|
|
|
if !procedure.save
|
|
|
|
print_procedure(procedure)
|
|
|
|
end
|
|
|
|
end
|
2018-09-13 18:20:01 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# Update task as completed. If you remove the line below, the task will
|
|
|
|
# run with every deploy (or every time you call after_party:run).
|
|
|
|
AfterParty::TaskRecord.create version: '20180913161001'
|
|
|
|
end
|
|
|
|
end
|