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.decorate
|
||||
|
||||
|
||||
@formulaire = @dossier.formulaire
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
@ -19,22 +18,21 @@ class DescriptionController < ApplicationController
|
|||
def create
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier.update_attributes(create_params)
|
||||
if !params[:cerfa_pdf].nil?
|
||||
unless params[:cerfa_pdf].nil?
|
||||
cerfa = @dossier.cerfa
|
||||
cerfa.content = params[:cerfa_pdf]
|
||||
cerfa.save
|
||||
end
|
||||
|
||||
|
||||
@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.save
|
||||
end
|
||||
end
|
||||
|
||||
if check_missing_attributes(params)||check_format_email(@dossier.mail_contact) == nil
|
||||
redirect_to url_for({controller: :description, action: :error})
|
||||
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
|
||||
|
@ -44,7 +42,7 @@ class DescriptionController < ApplicationController
|
|||
@commentaire.save
|
||||
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
|
||||
|
||||
|
@ -54,13 +52,13 @@ class DescriptionController < ApplicationController
|
|||
params.permit(:nom_projet, :description, :montant_projet, :montant_aide_demande, :date_previsionnelle, :lien_plus_infos, :mail_contact)
|
||||
end
|
||||
|
||||
#TODO dans un validateur, dans le model
|
||||
def check_missing_attributes params
|
||||
# TODO dans un validateur, dans le model
|
||||
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
|
||||
|
||||
#TODO dans un validateur, dans le model
|
||||
def check_format_email email
|
||||
# TODO dans un validateur, dans le model
|
||||
def check_format_email(email)
|
||||
/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/.match(email)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue