From c2f996393864e405ad806ba43c622b215fb60ac7 Mon Sep 17 00:00:00 2001 From: Tanguy PATTE Date: Thu, 20 Aug 2015 16:37:03 +0200 Subject: [PATCH] style check --- app/controllers/description_controller.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/controllers/description_controller.rb b/app/controllers/description_controller.rb index b77f58b32..b80e1d253 100644 --- a/app/controllers/description_controller.rb +++ b/app/controllers/description_controller.rb @@ -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