[fix 363] Dossier: remove next_step! role var

This commit is contained in:
Simon Lehericey 2017-12-05 17:16:38 +01:00 committed by LeSim
parent 201862d450
commit e78f5b3a2d

View file

@ -144,49 +144,32 @@ class Dossier < ActiveRecord::Base
champs.joins(', types_de_piece_justificative').where("pieces_justificatives.type_de_piece_justificative_id = types_de_piece_justificative.id AND types_de_piece_justificative.procedure_id = #{procedure.id}").order('order_place ASC') champs.joins(', types_de_piece_justificative').where("pieces_justificatives.type_de_piece_justificative_id = types_de_piece_justificative.id AND types_de_piece_justificative.procedure_id = #{procedure.id}").order('order_place ASC')
end end
def next_step! role, action, motivation = nil def next_step!(action, motivation = nil)
unless %w(receive refuse without_continuation close).include?(action) unless %w(receive refuse without_continuation close).include?(action)
fail 'action is not valid' fail 'action is not valid'
end end
unless %w(gestionnaire).include?(role) case action
fail 'role is not valid' when 'close'
if en_instruction?
self.attestation = build_attestation
save
accepte!
end
when 'refuse'
if en_instruction?
refuse!
end
when 'without_continuation'
if en_instruction?
sans_suite!
end
end end
case role if motivation
when 'gestionnaire' self.motivation = motivation
case action save
when 'close'
if en_instruction?
self.attestation = build_attestation
save
accepte!
if motivation
self.motivation = motivation
save
end
end
when 'refuse'
if en_instruction?
refuse!
if motivation
self.motivation = motivation
save
end
end
when 'without_continuation'
if en_instruction?
sans_suite!
if motivation
self.motivation = motivation
save
end
end
end
end end
state state