2015-09-28 18:55:16 +02:00
|
|
|
class Users::CarteController < ApplicationController
|
2015-08-12 14:02:40 +02:00
|
|
|
include DossierConcern
|
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
def show
|
2015-08-12 14:02:40 +02:00
|
|
|
@dossier = current_dossier
|
2015-08-18 10:43:22 +02:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
2015-09-28 18:55:16 +02:00
|
|
|
redirect_to url_for(controller: :dossiers, action: :index)
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def save_ref_api_carto
|
2015-08-12 14:02:40 +02:00
|
|
|
dossier = current_dossier
|
2015-09-28 18:55:16 +02:00
|
|
|
|
|
|
|
if dossier.draft?
|
2015-09-22 13:58:32 +02:00
|
|
|
dossier.update_attributes(ref_dossier_carto: params[:ref_dossier])
|
2015-08-20 16:34:14 +02:00
|
|
|
redirect_to url_for(controller: :description, action: :show, dossier_id: params[:dossier_id])
|
2015-08-18 10:43:22 +02:00
|
|
|
else
|
|
|
|
commentaire_params = {
|
|
|
|
email: 'Modification localisation',
|
|
|
|
body: 'La localisation de la demande a été modifiée. Merci de le prendre en compte.',
|
|
|
|
dossier_id: dossier.id
|
|
|
|
}
|
|
|
|
commentaire = Commentaire.new commentaire_params
|
2015-08-12 14:02:40 +02:00
|
|
|
commentaire.save
|
2015-08-20 16:34:14 +02:00
|
|
|
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params[:dossier_id])
|
2015-08-18 10:43:22 +02:00
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_position
|
2015-08-12 14:02:40 +02:00
|
|
|
dossier = current_dossier
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2015-08-20 16:34:14 +02:00
|
|
|
if dossier.position_lat.nil?
|
2015-08-12 14:02:40 +02:00
|
|
|
tmp_position = Carto::Geocodeur.convert_adresse_to_point(dossier.etablissement.adresse.gsub("\r\n", ' '))
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2015-08-20 16:34:14 +02:00
|
|
|
if tmp_position.point.nil?
|
2015-08-12 14:02:40 +02:00
|
|
|
dossier.update_attributes(position_lat: '0', position_lon: '0')
|
|
|
|
else
|
|
|
|
dossier.update_attributes(position_lat: tmp_position.point.y, position_lon: tmp_position.point.x)
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
2015-08-12 14:02:40 +02:00
|
|
|
render json: { lon: dossier.position_lon, lat: dossier.position_lat, dossier_id: params[:dossier_id] }
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
2015-08-20 16:34:14 +02:00
|
|
|
end
|