style check
This commit is contained in:
parent
49b1e49fd8
commit
c2f9963938
1 changed files with 9 additions and 11 deletions
|
@ -3,7 +3,6 @@ class DescriptionController < ApplicationController
|
||||||
@dossier = Dossier.find(params[:dossier_id])
|
@dossier = Dossier.find(params[:dossier_id])
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
|
|
||||||
|
|
||||||
@formulaire = @dossier.formulaire
|
@formulaire = @dossier.formulaire
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
@ -19,22 +18,21 @@ class DescriptionController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@dossier = Dossier.find(params[:dossier_id])
|
@dossier = Dossier.find(params[:dossier_id])
|
||||||
@dossier.update_attributes(create_params)
|
@dossier.update_attributes(create_params)
|
||||||
if !params[:cerfa_pdf].nil?
|
unless params[:cerfa_pdf].nil?
|
||||||
cerfa = @dossier.cerfa
|
cerfa = @dossier.cerfa
|
||||||
cerfa.content = params[:cerfa_pdf]
|
cerfa.content = params[:cerfa_pdf]
|
||||||
cerfa.save
|
cerfa.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@dossier.pieces_jointes.each do |piece_jointe|
|
@dossier.pieces_jointes.each do |piece_jointe|
|
||||||
if params["piece_jointe_#{piece_jointe.type}"] != nil
|
unless params["piece_jointe_#{piece_jointe.type}"].nil?
|
||||||
piece_jointe.content = params["piece_jointe_#{piece_jointe.id}"]
|
piece_jointe.content = params["piece_jointe_#{piece_jointe.id}"]
|
||||||
piece_jointe.save
|
piece_jointe.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if check_missing_attributes(params)||check_format_email(@dossier.mail_contact) == nil
|
if check_missing_attributes(params) || check_format_email(@dossier.mail_contact).nil?
|
||||||
redirect_to url_for({controller: :description, action: :error})
|
redirect_to url_for(controller: :description, action: :error)
|
||||||
else
|
else
|
||||||
if params[:back_url] == 'recapitulatif'
|
if params[:back_url] == 'recapitulatif'
|
||||||
@commentaire = Commentaire.create
|
@commentaire = Commentaire.create
|
||||||
|
@ -44,7 +42,7 @@ class DescriptionController < ApplicationController
|
||||||
@commentaire.save
|
@commentaire.save
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to url_for({controller: :recapitulatif, action: :show, dossier_id: @dossier.id})
|
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,13 +52,13 @@ class DescriptionController < ApplicationController
|
||||||
params.permit(:nom_projet, :description, :montant_projet, :montant_aide_demande, :date_previsionnelle, :lien_plus_infos, :mail_contact)
|
params.permit(:nom_projet, :description, :montant_projet, :montant_aide_demande, :date_previsionnelle, :lien_plus_infos, :mail_contact)
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO dans un validateur, dans le model
|
# TODO dans un validateur, dans le model
|
||||||
def check_missing_attributes params
|
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 == ''
|
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
|
end
|
||||||
|
|
||||||
#TODO dans un validateur, dans le model
|
# TODO dans un validateur, dans le model
|
||||||
def check_format_email email
|
def check_format_email(email)
|
||||||
/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/.match(email)
|
/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/.match(email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue