2015-10-09 14:43:19 +02:00
|
|
|
class Users::DescriptionController < UsersController
|
2015-08-10 11:05:06 +02:00
|
|
|
def show
|
|
|
|
@dossier = Dossier.find(params[:dossier_id])
|
|
|
|
@dossier = @dossier.decorate
|
2015-08-11 15:39:16 +02:00
|
|
|
|
2015-09-21 17:59:03 +02:00
|
|
|
@procedure = @dossier.procedure
|
2015-08-20 12:20:54 +02:00
|
|
|
|
2015-08-18 10:43:36 +02:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
2015-09-23 16:56:30 +02:00
|
|
|
flash.alert = t('errors.messages.dossier_not_found')
|
|
|
|
redirect_to url_for(controller: :siret)
|
2015-08-10 11:05:06 +02:00
|
|
|
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])
|
2015-08-21 11:37:13 +02:00
|
|
|
unless @dossier.update_attributes(create_params)
|
|
|
|
@dossier = @dossier.decorate
|
2015-09-21 17:59:03 +02:00
|
|
|
@procedure = @dossier.procedure
|
2015-08-21 11:37:13 +02:00
|
|
|
|
|
|
|
flash.now.alert = @dossier.errors.full_messages.join('<br />').html_safe
|
|
|
|
return render 'show'
|
|
|
|
end
|
2015-08-20 16:37:03 +02:00
|
|
|
unless params[:cerfa_pdf].nil?
|
2015-08-20 15:15:20 +02:00
|
|
|
cerfa = @dossier.cerfa
|
|
|
|
cerfa.content = params[:cerfa_pdf]
|
|
|
|
cerfa.save
|
2015-08-11 15:39:16 +02:00
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2015-09-21 17:59:03 +02:00
|
|
|
@dossier.pieces_justificatives.each do |piece_justificative|
|
|
|
|
unless params["piece_justificative_#{piece_justificative.type}"].nil?
|
|
|
|
piece_justificative.content = params["piece_justificative_#{piece_justificative.type}"]
|
|
|
|
piece_justificative.save
|
2015-08-11 15:39:16 +02:00
|
|
|
end
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2015-09-28 10:32:41 +02:00
|
|
|
if !@dossier.draft?
|
|
|
|
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
|
|
|
|
else
|
|
|
|
@dossier.proposed!
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
|
2015-09-28 10:32:41 +02:00
|
|
|
flash.notice = 'Félicitation, votre demande a bien été enregistrée.'
|
|
|
|
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
2015-08-25 10:19:39 +02:00
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-08-11 15:39:16 +02:00
|
|
|
def create_params
|
2015-09-22 13:58:32 +02:00
|
|
|
params.permit(:nom_projet, :description, :montant_projet, :montant_aide_demande, :date_previsionnelle)
|
2015-08-11 15:39:16 +02:00
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|