First Commit
This commit is contained in:
commit
b5b83e939a
213 changed files with 8688 additions and 0 deletions
31
app/controllers/admin/dossier_controller.rb
Normal file
31
app/controllers/admin/dossier_controller.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
class Admin::DossierController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@entreprise = @dossier.entreprise.decorate
|
||||
@etablissement = @dossier.etablissement.decorate
|
||||
@dossier_pdf = @dossier.dossier_pdf
|
||||
|
||||
@commentaires = @dossier.commentaires.order(created_at: :desc)
|
||||
@commentaires = @commentaires.all.decorate
|
||||
@commentaire_email = current_user.email
|
||||
|
||||
@dossier = @dossier.decorate
|
||||
rescue
|
||||
redirect_start
|
||||
end
|
||||
|
||||
def index
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
redirect_to url_for({controller: 'admin/dossier', action: :show, :dossier_id => @dossier.id})
|
||||
rescue
|
||||
redirect_start
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def redirect_start
|
||||
redirect_to url_for({controller: '/start', action: :error_dossier})
|
||||
end
|
||||
end
|
22
app/controllers/application_controller.rb
Normal file
22
app/controllers/application_controller.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
before_filter :store_location
|
||||
|
||||
def store_location
|
||||
unless params[:controller] == "devise/sessions"
|
||||
url = "/admin/dossier/#{params[:dossier_id]}"
|
||||
session[:user_return_to] = url
|
||||
end
|
||||
end
|
||||
|
||||
def stored_location_for(resource_or_scope)
|
||||
session[:user_return_to] || super
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
stored_location_for(resource) || root_path
|
||||
end
|
||||
end
|
40
app/controllers/carte_controller.rb
Normal file
40
app/controllers/carte_controller.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
class CarteController < ApplicationController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
rescue
|
||||
redirect_to url_for({controller: :start, action: :error_dossier})
|
||||
end
|
||||
|
||||
def save_ref_api_carto
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier.ref_dossier = params[:ref_dossier]
|
||||
@dossier.save
|
||||
|
||||
if params[:back_url] == 'recapitulatif'
|
||||
@commentaire = Commentaire.create
|
||||
@commentaire.email = 'Modification localisation'
|
||||
@commentaire.body = 'La localisation de la demande a été modifiée. Merci de le prendre en compte.'
|
||||
@commentaire.dossier = @dossier
|
||||
@commentaire.save
|
||||
|
||||
redirect_to url_for({controller: :recapitulatif, action: :show, :dossier_id => params[:dossier_id]})
|
||||
else
|
||||
redirect_to url_for({controller: :description, action: :show, :dossier_id => params[:dossier_id]})
|
||||
end
|
||||
end
|
||||
|
||||
def get_position
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
|
||||
if @dossier.position_lat == nil
|
||||
tmp_position = Carto::Geocodeur.convert_adresse_to_point(@dossier.etablissement.adresse.gsub("\r\n", ' '))
|
||||
|
||||
@dossier.position_lat = tmp_position.point.y
|
||||
@dossier.position_lon = tmp_position.point.x
|
||||
|
||||
@dossier.save
|
||||
end
|
||||
|
||||
render json: { lon: @dossier.position_lon, lat: @dossier.position_lat, dossier_id: params[:dossier_id] }
|
||||
end
|
||||
end
|
17
app/controllers/commentaires_controller.rb
Normal file
17
app/controllers/commentaires_controller.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class CommentairesController < ApplicationController
|
||||
def create
|
||||
@commentaire = Commentaire.create
|
||||
@commentaire.email = params['email_commentaire']
|
||||
@commentaire.body = params['texte_commentaire']
|
||||
@commentaire.dossier = Dossier.find(params['dossier_id'])
|
||||
|
||||
@commentaire.save
|
||||
|
||||
if request.referer.include?'/recapitulatif'
|
||||
redirect_to url_for({controller: :recapitulatif, action: :show, :dossier_id => params['dossier_id']})
|
||||
else
|
||||
redirect_to url_for({controller: 'admin/dossier', action: :show, :dossier_id => params['dossier_id']})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
0
app/controllers/concerns/.keep
Normal file
0
app/controllers/concerns/.keep
Normal file
14
app/controllers/demandes_controller.rb
Normal file
14
app/controllers/demandes_controller.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class DemandesController < ApplicationController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@evenement_vie = EvenementVie.where(use_admi_facile: true)
|
||||
end
|
||||
|
||||
def choice
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier.ref_formulaire = params[:ref_formulaire]
|
||||
@dossier.save
|
||||
|
||||
redirect_to url_for({controller: :carte, action: :show, :dossier_id => params[:dossier_id]})
|
||||
end
|
||||
end
|
59
app/controllers/description_controller.rb
Normal file
59
app/controllers/description_controller.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
class DescriptionController < ApplicationController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier = @dossier.decorate
|
||||
rescue
|
||||
redirect_to url_for({controller: :start, action: :error_dossier})
|
||||
end
|
||||
|
||||
def error
|
||||
show
|
||||
flash.now.alert = 'Un ou plusieurs attributs obligatoires sont manquants ou incorrects.'
|
||||
render 'show'
|
||||
end
|
||||
|
||||
def create
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
|
||||
@dossier.nom_projet = params[:nom_projet]
|
||||
@dossier.description = params[:description]
|
||||
@dossier.montant_projet = params[:montant_projet]
|
||||
@dossier.montant_aide_demande = params[:montant_aide_demande]
|
||||
@dossier.date_previsionnelle = params[:date_previsionnelle]
|
||||
@dossier.lien_plus_infos = params[:lien_plus_infos]
|
||||
@dossier.mail_contact = params[:mail_contact]
|
||||
|
||||
@dossier.save
|
||||
|
||||
#upload dossier pdf
|
||||
|
||||
@dossier_pdf = DossierPdf.new
|
||||
@dossier_pdf.ref_dossier_pdf = params[:dossier_pdf]
|
||||
@dossier_pdf.dossier = @dossier
|
||||
@dossier_pdf.save!
|
||||
|
||||
if check_missing_attributes(params)||check_format_email(@dossier.mail_contact) == nil
|
||||
redirect_to url_for({controller: :description, action: :error})
|
||||
else
|
||||
if params[:back_url] == 'recapitulatif'
|
||||
@commentaire = Commentaire.create
|
||||
@commentaire.email = 'Modification détails'
|
||||
@commentaire.body = 'Les informations détaillées de la demande ont été modifiées. Merci de le prendre en compte.'
|
||||
@commentaire.dossier = @dossier
|
||||
@commentaire.save
|
||||
end
|
||||
|
||||
redirect_to url_for({controller: :recapitulatif, action: :show, dossier_id: @dossier.id})
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_missing_attributes params
|
||||
params[:nom_projet].strip == '' || params[:description].strip == '' || params[:montant_projet].strip == '' || params[:montant_aide_demande].strip == '' || params[:date_previsionnelle].strip == '' || params[:mail_contact].strip == ''
|
||||
end
|
||||
|
||||
def check_format_email email
|
||||
/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/.match(email)
|
||||
end
|
||||
end
|
66
app/controllers/dossiers_controller.rb
Normal file
66
app/controllers/dossiers_controller.rb
Normal file
|
@ -0,0 +1,66 @@
|
|||
class DossiersController < ApplicationController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:id])
|
||||
|
||||
@etablissement = @dossier.etablissement.decorate
|
||||
@entreprise = @dossier.entreprise.decorate
|
||||
rescue
|
||||
redirect_to url_for({controller: :start, action: :error_dossier})
|
||||
end
|
||||
|
||||
def create
|
||||
@rescue_redirect = 'error_siret'
|
||||
|
||||
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(params[:siret]).to_params)
|
||||
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(params[:siret][0..-6]).to_params)
|
||||
|
||||
@dossier_id = params[:pro_dossier_id].strip
|
||||
|
||||
if @dossier_id != ""
|
||||
@rescue_redirect = 'error_dossier'
|
||||
|
||||
@dossier = Dossier.find(@dossier_id)
|
||||
@etablissement = @dossier.etablissement
|
||||
|
||||
if @etablissement.siret == params[:siret]
|
||||
redirect_to url_for({controller: :recapitulatif, action: :show, dossier_id: @dossier_id})
|
||||
else
|
||||
raise 'Combinaison Dossier_ID / SIRET non valide'
|
||||
end
|
||||
else
|
||||
@dossier = Dossier.create
|
||||
|
||||
@entreprise.dossier = @dossier
|
||||
@entreprise.save
|
||||
|
||||
@etablissement.dossier = @dossier
|
||||
@etablissement.entreprise = @entreprise
|
||||
@etablissement.save
|
||||
|
||||
redirect_to url_for({controller: :dossiers, action: :show, id: @dossier.id})
|
||||
end
|
||||
rescue
|
||||
redirect_to url_for({controller: :start, action: @rescue_redirect})
|
||||
end
|
||||
|
||||
def update
|
||||
@dossier = Dossier.find(params[:id])
|
||||
@dossier.autorisation_donnees = (params[:autorisation_donnees] == 'on')
|
||||
@dossier.save
|
||||
|
||||
if @dossier.autorisation_donnees
|
||||
redirect_to url_for({controller: :demandes, action: :show, dossier_id: @dossier.id})
|
||||
else
|
||||
@etablissement = @dossier.etablissement.decorate
|
||||
@entreprise = @dossier.entreprise.decorate
|
||||
|
||||
self.error
|
||||
end
|
||||
end
|
||||
|
||||
def error
|
||||
show
|
||||
flash.now.alert = 'Les conditions sont obligatoires.'
|
||||
render 'show'
|
||||
end
|
||||
end
|
25
app/controllers/pros/sessions_controller.rb
Normal file
25
app/controllers/pros/sessions_controller.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
class Pros::SessionsController < Devise::SessionsController
|
||||
# before_filter :configure_sign_in_params, only: [:create]
|
||||
|
||||
#GET /resource/sign_in
|
||||
def new
|
||||
super
|
||||
end
|
||||
|
||||
#POST /resource/sign_in
|
||||
def create
|
||||
super
|
||||
end
|
||||
|
||||
# DELETE /resource/sign_out
|
||||
# def destroy
|
||||
# super
|
||||
# end
|
||||
|
||||
# protected
|
||||
|
||||
# You can put the params you want to permit in the empty array.
|
||||
# def configure_sign_in_params
|
||||
# devise_parameter_sanitizer.for(:sign_in) << :attribute
|
||||
# end
|
||||
end
|
12
app/controllers/recapitulatif_controller.rb
Normal file
12
app/controllers/recapitulatif_controller.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class RecapitulatifController < ApplicationController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier = @dossier.decorate
|
||||
|
||||
@commentaires = @dossier.commentaires.order(created_at: :desc)
|
||||
@commentaires = @commentaires.all.decorate
|
||||
@commentaire_email = @dossier.mail_contact
|
||||
rescue
|
||||
redirect_to url_for({controller: :start, action: :error_dossier})
|
||||
end
|
||||
end
|
17
app/controllers/start_controller.rb
Normal file
17
app/controllers/start_controller.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class StartController < ApplicationController
|
||||
def index
|
||||
|
||||
end
|
||||
def error_siret
|
||||
flash.now.alert = 'Ce SIRET n\'est pas valide'
|
||||
render 'index'
|
||||
end
|
||||
def error_login
|
||||
flash.now.alert = 'Ce compte n\'existe pas'
|
||||
render 'index'
|
||||
end
|
||||
def error_dossier
|
||||
flash.now.alert = 'Ce dossier n\'existe pas'
|
||||
render 'index'
|
||||
end
|
||||
end
|
14
app/controllers/user/custom_failure.rb
Normal file
14
app/controllers/user/custom_failure.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class User::CustomFailure < Devise::FailureApp
|
||||
def redirect_url
|
||||
url_for({controller: '/start', action: :index})
|
||||
end
|
||||
|
||||
# You need to override respond to eliminate recall
|
||||
def respond
|
||||
if http_auth?
|
||||
http_auth
|
||||
else
|
||||
redirect
|
||||
end
|
||||
end
|
||||
end
|
25
app/controllers/user/sessions_controller.rb
Normal file
25
app/controllers/user/sessions_controller.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
class User::SessionsController < Devise::SessionsController
|
||||
# before_filter :configure_sign_in_params, only: [:create]
|
||||
|
||||
# GET /resource/sign_in
|
||||
def new
|
||||
redirect_to url_for({controller: '/start', action: :error_login})
|
||||
end
|
||||
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
super
|
||||
end
|
||||
|
||||
# DELETE /resource/sign_out
|
||||
def destroy
|
||||
super
|
||||
end
|
||||
|
||||
# protected
|
||||
|
||||
# You can put the params you want to permit in the empty array.
|
||||
# def configure_sign_in_params
|
||||
# devise_parameter_sanitizer.for(:sign_in) << :attribute
|
||||
# end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue