demarches-normaliennes/app/controllers/new_gestionnaire/dossiers_controller.rb
2017-09-06 11:11:28 +02:00

70 lines
1.8 KiB
Ruby
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module NewGestionnaire
class DossiersController < ProceduresController
def attestation
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
def show
@dossier = dossier
end
def messagerie
@dossier = dossier
end
def follow
current_gestionnaire.follow(dossier)
dossier.next_step!('gestionnaire', 'follow')
flash.notice = 'Dossier suivi'
redirect_back(fallback_location: procedures_url)
end
def unfollow
current_gestionnaire.followed_dossiers.delete(dossier)
flash.notice = "Vous ne suivez plus le dossier nº #{dossier.id}"
redirect_back(fallback_location: procedures_url)
end
def archive
dossier.update_attributes(archived: true)
redirect_back(fallback_location: procedures_url)
end
def unarchive
dossier.update_attributes(archived: false)
redirect_back(fallback_location: procedures_url)
end
def create_commentaire
Commentaire.create(commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier))
redirect_to messagerie_dossier_path(dossier.procedure, dossier)
end
def position
etablissement = dossier.etablissement
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) unless etablissement.nil?
lon = "2.428462"
lat = "46.538192"
zoom = "13"
unless point.nil?
lon = point.x.to_s
lat = point.y.to_s
end
render json: { lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id] }
end
private
def dossier
current_gestionnaire.dossiers.find(params[:dossier_id])
end
def commentaire_params
params.require(:commentaire).permit(:body)
end
end
end