2016-05-24 16:39:39 +02:00
|
|
|
class AccompagnateurService
|
|
|
|
ASSIGN = 'assign'
|
|
|
|
NOT_ASSIGN = 'not_assign'
|
|
|
|
|
2016-10-07 12:10:58 +02:00
|
|
|
def initialize accompagnateur, procedure, to
|
|
|
|
@accompagnateur = accompagnateur
|
|
|
|
@procedure = procedure
|
|
|
|
@to = to
|
2016-05-24 16:39:39 +02:00
|
|
|
end
|
2016-09-08 16:21:54 +02:00
|
|
|
|
2016-10-07 12:10:58 +02:00
|
|
|
def change_assignement!
|
|
|
|
if @to == ASSIGN
|
|
|
|
AssignTo.create(gestionnaire: @accompagnateur, procedure: @procedure)
|
|
|
|
elsif @to == NOT_ASSIGN
|
|
|
|
AssignTo.delete_all(gestionnaire: @accompagnateur, procedure: @procedure)
|
|
|
|
end
|
|
|
|
end
|
2016-09-08 16:21:54 +02:00
|
|
|
|
2016-10-07 12:10:58 +02:00
|
|
|
def build_default_column
|
|
|
|
return unless @to == ASSIGN
|
|
|
|
return unless PreferenceListDossier.where(gestionnaire: @accompagnateur, procedure: @procedure).empty?
|
2016-09-08 16:21:54 +02:00
|
|
|
|
2016-10-07 12:10:58 +02:00
|
|
|
@accompagnateur.build_default_preferences_list_dossier @procedure.id
|
2016-09-08 16:21:54 +02:00
|
|
|
end
|
2016-05-24 16:39:39 +02:00
|
|
|
end
|