demarches-normaliennes/app/facades/dossier_facades.rb

68 lines
1.3 KiB
Ruby
Raw Normal View History

class DossierFacades
# TODO rechercher en fonction de la personne/email
2016-11-14 18:00:26 +01:00
def initialize(dossier_id, email, champ_id = nil)
2017-02-27 17:44:08 +01:00
@dossier = Dossier.find(dossier_id)
2016-11-14 18:00:26 +01:00
@champ_id = champ_id
end
def dossier
@dossier.decorate
end
def champs
@dossier.ordered_champs
end
def entreprise
2018-01-11 19:04:39 +01:00
@dossier.entreprise.decorate if @dossier.entreprise.present? && @dossier.entreprise.siren.present?
end
def etablissement
@dossier.etablissement
end
def pieces_justificatives
2016-10-07 15:16:03 +02:00
@dossier.ordered_pieces_justificatives
end
2016-12-22 10:55:27 +01:00
def types_de_pieces_justificatives
@dossier.types_de_piece_justificative.order('order_place ASC')
end
2016-11-14 18:00:26 +01:00
def champ_id
@champ_id
end
def commentaires
@dossier.commentaires.where(champ_id: @champ_id).decorate
end
def procedure
@dossier.procedure
end
def cerfas_ordered
@dossier.cerfa.order('created_at DESC')
end
def invites
@dossier.invites
end
def champs_private
@dossier.ordered_champs_private
end
2016-08-30 11:18:43 +02:00
def individual
@dossier.individual
end
def commentaires_files
PieceJustificative.where(dossier_id: @dossier.id, type_de_piece_justificative_id: nil)
end
def followers
Gestionnaire.joins(:follows).where("follows.dossier_id=#{@dossier.id}")
end
2016-11-14 18:00:26 +01:00
end