!foo.nil? -> foo.present?

This commit is contained in:
gregoirenovel 2018-01-11 19:08:04 +01:00
parent 3dd03a04cd
commit bbaebe0602
12 changed files with 16 additions and 16 deletions

View file

@ -9,7 +9,7 @@ class APIController < ApplicationController
protected
def valid_token?
!current_administrateur.nil?
current_administrateur.present?
end
def current_administrateur

View file

@ -1,7 +1,7 @@
class Users::Dossiers::InvitesController < UsersController
def authenticate_user!
session["user_return_to"] = request.fullpath
return redirect_to new_user_registration_path(user_email: params[:email]) if !params[:email].blank? && User.find_by_email(params[:email]).nil?
return redirect_to new_user_registration_path(user_email: params[:email]) if params[:email].present? && User.find_by_email(params[:email]).nil?
super
end

View file

@ -5,7 +5,7 @@ class Cerfa < ActiveRecord::Base
mount_uploader :content, CerfaUploader
validates :content, :file_size => {:maximum => 20.megabytes}
after_save :internal_notification, if: Proc.new { !dossier.nil? }
after_save :internal_notification, if: Proc.new { dossier.present? }
def empty?
content.blank?

View file

@ -9,7 +9,7 @@ class Champ < ActiveRecord::Base
before_save :serialize_datetime_if_needed, if: Proc.new { type_champ == 'datetime' }
before_save :multiple_select_to_string, if: Proc.new { type_champ == 'multiple_drop_down_list' }
after_save :internal_notification, if: Proc.new { !dossier.nil? }
after_save :internal_notification, if: Proc.new { dossier.present? }
scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) }
@ -39,7 +39,7 @@ class Champ < ActiveRecord::Base
end
def same_date? num, compare
if type_champ == 'datetime' && !value.nil?
if type_champ == 'datetime' && value.present?
if value.to_datetime.strftime(compare) == num
return true
end

View file

@ -7,7 +7,7 @@ class DropDownList < ActiveRecord::Base
end
def disabled_options
options.select{ |v| !(v =~ /^--.*--$/).nil? }
options.select{ |v| (v =~ /^--.*--$/).present? }
end
def selected_options(champ)

View file

@ -13,7 +13,7 @@ class PieceJustificative < ActiveRecord::Base
validates :content, :file_size => {:maximum => 20.megabytes}
validates :content, presence: true, allow_blank: false, allow_nil: false
after_save :internal_notification, if: Proc.new { !dossier.nil? }
after_save :internal_notification, if: Proc.new { dossier.present? }
scope :updated_since?, -> (date) { where('pieces_justificatives.updated_at > ?', date) }

View file

@ -31,7 +31,7 @@ class User < ActiveRecord::Base
end
def loged_in_with_france_connect?
!loged_in_with_france_connect.nil?
loged_in_with_france_connect.present?
end
def invite? dossier_id

View file

@ -12,14 +12,14 @@ class SwitchDeviseProfileService
private
def user_signed_in?
!@warden.authenticate(:scope => :user).nil?
@warden.authenticate(:scope => :user).present?
end
def gestionnaire_signed_in?
!@warden.authenticate(:scope => :gestionnaire).nil?
@warden.authenticate(:scope => :gestionnaire).present?
end
def administrateur_signed_in?
!@warden.authenticate(:scope => :administrateur).nil?
@warden.authenticate(:scope => :administrateur).present?
end
end

View file

@ -91,7 +91,7 @@
.col-xs-5.despositaire-info
- if type_de_piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous.
- elsif !(@pj = @facade.dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id)).nil?
- elsif (@pj = @facade.dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id)).present?
%a{ href: "#{@pj.content_url}", target: '_blank' } Consulter
%span{ style: 'margin-left: 12px;' }
\-

View file

@ -29,7 +29,7 @@
.col-xs-6
- if type_de_piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous.
- elsif !(@pj = @facade.dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id)).nil?
- elsif (@pj = @facade.dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id)).present?
-# - if user_signed_in?
-# = 'Pièce fournie'
-# - elsif gestionnaire_signed_in?

View file

@ -25,7 +25,7 @@
%td.col-lg-6.col-md-6.col-sm-6.col-xs-6
- if type_de_piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous.
- elsif !(@pj = @facade.dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id)).nil?
- elsif (@pj = @facade.dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id)).present?
-# - if user_signed_in?
-# = 'Pièce fournie'
-# - elsif gestionnaire_signed_in?

View file

@ -44,7 +44,7 @@ namespace :cloudstorage do
error_count += 1
end
else
if !content.current_path.nil? && File.exist?(File.dirname(content.current_path) + '/uploaded')
if content.current_path.present? && File.exist?(File.dirname(content.current_path) + '/uploaded')
filename = File.open(File.dirname(content.current_path) + '/filename_cloudstorage', "r").read
secure_token = File.open(File.dirname(content.current_path) + '/secure_token_cloudstorage', "r").read
@ -52,7 +52,7 @@ namespace :cloudstorage do
entry.update_column(c == Procedure ? :logo_secure_token : :content_secure_token, secure_token)
puts "RESTORE IN DATABASE: #{filename} "
elsif !content.current_path.nil?
elsif content.current_path.present?
puts "Skipping #{content.current_path}"
end
end