Merge pull request #1246 from betagouv/unless

Unless
This commit is contained in:
gregoirenovel 2018-01-15 09:53:24 +01:00 committed by GitHub
commit 1c295eafb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 185 additions and 178 deletions

View file

@ -579,7 +579,7 @@ Rails/PluralizationGrammar:
Enabled: false
Rails/Present:
Enabled: false
Enabled: true
Rails/ReadWriteAttribute:
Enabled: false
@ -1029,7 +1029,7 @@ Style/TrivialAccessors:
Enabled: false
Style/UnlessElse:
Enabled: false
Enabled: true
Style/UnneededCapitalW:
Enabled: false

View file

@ -11,7 +11,7 @@ class Admin::ChangeDossierStateController < AdminController
def check
@dossier = Dossier.find(params[:dossier][:id])
unless @dossier.procedure.administrateur.email == current_administrateur.email
if @dossier.procedure.administrateur.email != current_administrateur.email
flash.alert = 'Dossier introuvable'
return redirect_to admin_change_dossier_state_path
end

View file

@ -71,7 +71,7 @@ class Admin::ProceduresController < AdminController
@procedure = Procedure.new(procedure_params)
@procedure.module_api_carto = ModuleAPICarto.new(create_module_api_carto_params) if @procedure.valid?
unless @procedure.save
if !@procedure.save
flash.now.alert = @procedure.errors.full_messages
return render 'new'
end
@ -83,7 +83,7 @@ class Admin::ProceduresController < AdminController
def update
@procedure = current_administrateur.procedures.find(params[:id])
unless @procedure.update_attributes(procedure_params)
if !@procedure.update_attributes(procedure_params)
flash.now.alert = @procedure.errors.full_messages
return render 'edit'
end

View file

@ -3,13 +3,13 @@ class APIController < ApplicationController
before_action :default_format_json
def authenticate_user
render json: {}, status: 401 unless valid_token?
render json: {}, status: 401 if !valid_token?
end
protected
def valid_token?
!current_administrateur.nil?
current_administrateur.present?
end
def current_administrateur
@ -17,6 +17,6 @@ class APIController < ApplicationController
end
def default_format_json
request.format = "json" unless request.params[:format]
request.format = "json" if !request.params[:format]
end
end

View file

@ -29,7 +29,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
dossier_id = params[:id]
create_dossier_facade dossier_id
unless @facade.nil?
if @facade.present?
@champs_private = @facade.champs_private
@headers_private = @champs_private.select { |champ| champ.type_champ == 'header_section' }
@ -72,7 +72,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
@dossiers = Dossier.none if @dossiers.nil?
# full text search
unless @dossiers.any?
if !@dossiers.any?
@dossiers = Search.new(
gestionnaire: current_gestionnaire,
query: @search_terms,
@ -161,7 +161,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
def archive
facade = create_dossier_facade params[:id]
unless facade.dossier.archived
if !facade.dossier.archived
facade.dossier.update(archived: true)
flash.notice = 'Dossier archivé'
end
@ -205,7 +205,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
end
def ensure_gestionnaire_is_authorized
unless current_gestionnaire.can_view_dossier?(params[:id])
if !current_gestionnaire.can_view_dossier?(params[:id])
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(controller: '/backoffice')
end

View file

@ -7,12 +7,12 @@ class Backoffice::DossiersListController < ApplicationController
def index
cookies[:liste] = param_liste
unless DossiersListGestionnaireService.dossiers_liste_libelle.include?(param_liste)
if !DossiersListGestionnaireService.dossiers_liste_libelle.include?(param_liste)
cookies[:liste] = 'all_state'
end
dossiers_list_facade param_liste
dossiers_list_facade.service.change_sort! param_sort unless param_smart_listing.nil?
dossiers_list_facade.service.change_sort! param_sort if param_smart_listing.present?
dossiers_list_facade.service.change_page! param_page
smartlisting_dossier
@ -58,14 +58,14 @@ class Backoffice::DossiersListController < ApplicationController
end
def param_page
unless param_smart_listing.nil?
if param_smart_listing.present?
return 1 if params[:dossiers_smart_listing][:page].blank?
params[:dossiers_smart_listing][:page]
end
end
def param_sort
params[:dossiers_smart_listing][:sort] unless param_smart_listing.nil?
params[:dossiers_smart_listing][:sort] if param_smart_listing.present?
end
def param_filter

View file

@ -4,7 +4,7 @@ class Backoffice::PrivateFormulairesController < ApplicationController
def update
dossier = current_gestionnaire.dossiers.find(params[:dossier_id])
unless params[:champs].nil?
if params[:champs].present?
ChampsService.save_champs dossier.champs_private, params
champs_service_errors = ChampsService.build_error_messages(dossier.champs_private)

View file

@ -10,7 +10,7 @@ class Ban::SearchController < ApplicationController
def get_address_point
point = Carto::Geocodeur.convert_adresse_to_point(params[:request])
unless point.nil?
if point.present?
lon = point.x.to_s
lat = point.y.to_s
end

View file

@ -14,11 +14,11 @@ class FranceConnect::ParticulierController < ApplicationController
end
def callback
return redirect_to new_user_session_path unless params.has_key?(:code)
return redirect_to new_user_session_path if !params.has_key?(:code)
user_infos = FranceConnectService.retrieve_user_informations_particulier(params[:code])
unless user_infos.nil?
if user_infos.present?
france_connect_information = FranceConnectInformation.find_by_france_connect_particulier user_infos
france_connect_information = FranceConnectInformation.create(
@ -44,7 +44,7 @@ class FranceConnect::ParticulierController < ApplicationController
end
def new
return redirect_france_connect_error_connection unless valid_salt_and_fci_id_params?
return redirect_france_connect_error_connection if !valid_salt_and_fci_id_params?
france_connect_information = FranceConnectInformation.find(params[:fci_id])
@user = User.new(france_connect_information: france_connect_information).decorate
@ -53,13 +53,13 @@ class FranceConnect::ParticulierController < ApplicationController
end
def check_email
return redirect_france_connect_error_connection unless valid_salt_and_fci_id_params?
return redirect_france_connect_error_connection if !valid_salt_and_fci_id_params?
user = User.find_by_email(params[:user][:email_france_connect])
return create if user.nil?
unless params[:user][:password].nil?
if params[:user][:password].present?
if user.valid_password?(params[:user][:password])
user.france_connect_information = FranceConnectInformation.find(params[:fci_id])
@ -80,7 +80,7 @@ class FranceConnect::ParticulierController < ApplicationController
user = User.new email: params[:user][:email_france_connect]
user.password = Devise.friendly_token[0, 20]
unless user.valid?
if !user.valid?
flash.alert = 'Email non valide'
return redirect_to france_connect_particulier_new_path fci_id: params[:fci_id], salt: params[:salt], user: {email_france_connect: params[:user]['email_france_connect']}

View file

@ -13,8 +13,11 @@ class InvitesController < ApplicationController
invite = class_var.create(dossier: dossier, user: user, email: email, email_sender: email_sender)
if invite.valid?
InviteMailer.invite_user(invite).deliver_now! unless invite.user.nil?
InviteMailer.invite_guest(invite).deliver_now! if invite.user.nil?
if invite.user.present?
InviteMailer.invite_user(invite).deliver_now!
else
InviteMailer.invite_guest(invite).deliver_now!
end
flash.notice = "Invitation envoyée (#{invite.email})"
else
@ -31,7 +34,9 @@ class InvitesController < ApplicationController
private
def gestionnaire_or_user?
return redirect_to root_path unless user_signed_in? || gestionnaire_signed_in?
if !user_signed_in? && !gestionnaire_signed_in?
return redirect_to root_path
end
@current_devise_profil = current_user if user_signed_in?
@current_devise_profil = current_gestionnaire if gestionnaire_signed_in?

View file

@ -136,13 +136,13 @@ module NewGestionnaire
def position
etablissement = dossier.etablissement
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) unless etablissement.nil?
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) if etablissement.present?
lon = "2.428462"
lat = "46.538192"
zoom = "13"
unless point.nil?
if point.present?
lon = point.x.to_s
lat = point.y.to_s
end

View file

@ -17,7 +17,7 @@ class Users::CarteController < UsersController
dossier.quartier_prioritaires.each(&:destroy)
dossier.cadastres.each(&:destroy)
unless params[:json_latlngs].blank?
if params[:json_latlngs].present?
ModuleApiCartoService.save_qp! dossier, params[:json_latlngs]
ModuleApiCartoService.save_cadastre! dossier, params[:json_latlngs]
end
@ -37,13 +37,13 @@ class Users::CarteController < UsersController
etablissement = nil
end
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) unless etablissement.nil?
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) if etablissement.present?
lon = '2.428462'
lat = '46.538192'
zoom = '13'
unless point.nil?
if point.present?
lon = point.x.to_s
lat = point.y.to_s
end

View file

@ -14,7 +14,7 @@ class Users::DescriptionController < UsersController
@headers = @champs.select { |c| c.type_champ == 'header_section' }
unless @dossier.can_be_en_construction?
if !@dossier.can_be_en_construction?
flash[:alert] = t('errors.messages.procedure_archived')
end
@ -27,13 +27,13 @@ class Users::DescriptionController < UsersController
dossier = current_user_dossier
procedure = dossier.procedure
return head :forbidden unless dossier.can_be_en_construction?
return head :forbidden if !dossier.can_be_en_construction?
ChampsService.save_champs(dossier.champs, params) if params[:champs]
if procedure.cerfa_flag? && params[:cerfa_pdf]
cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: dossier, user: current_user)
return redirect_to_description_with_errors(dossier, cerfa.errors.full_messages) unless cerfa.save
return redirect_to_description_with_errors(dossier, cerfa.errors.full_messages) if !cerfa.save
end
errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params)
@ -69,15 +69,15 @@ class Users::DescriptionController < UsersController
@dossier ||= current_user_dossier
if @dossier.procedure.cerfa_flag?
unless params[:cerfa_pdf].nil?
if params[:cerfa_pdf].present?
cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user)
unless cerfa.save
if !cerfa.save
flash.alert = cerfa.errors.full_messages
end
end
end
if !((errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).empty?)
if (errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).present?
if flash.alert.nil?
flash.alert = errors_upload
else

View file

@ -2,9 +2,9 @@ class Users::Dossiers::AddSiretController < ApplicationController
def show
@facade = DossierFacades.new params[:dossier_id], current_user.email
raise ActiveRecord::RecordNotFound unless @facade.procedure.individual_with_siret?
raise ActiveRecord::RecordNotFound if !@facade.procedure.individual_with_siret?
@siret = current_user.siret unless current_user.siret.nil?
@siret = current_user.siret if current_user.siret.present?
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')

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

@ -36,7 +36,7 @@ class Users::DossiersController < UsersController
end
def commencer
unless params[:procedure_path].nil?
if params[:procedure_path].present?
procedure_path = ProcedurePath.where(path: params[:procedure_path]).last
if procedure_path.nil? || procedure_path.procedure.nil?
@ -65,7 +65,7 @@ class Users::DossiersController < UsersController
dossier = Dossier.create(procedure: procedure, user: current_user, state: 'brouillon')
siret = params[:siret] || current_user.siret
update_current_user_siret! siret unless siret.nil?
update_current_user_siret! siret if siret.present?
redirect_to users_dossier_path(id: dossier.id)
rescue ActiveRecord::RecordNotFound
@ -74,7 +74,7 @@ class Users::DossiersController < UsersController
def show
@facade = facade
@siret = current_user.siret unless current_user.siret.nil?
@siret = current_user.siret if current_user.siret.present?
if @facade.procedure.for_individual? && current_user.loged_in_with_france_connect?
individual = @facade.dossier.individual
@ -135,7 +135,7 @@ class Users::DossiersController < UsersController
flash.alert = individual_errors
redirect_to users_dossier_path(id: @facade.dossier.id)
else
unless Dossier.find(@facade.dossier.id).update_attributes update_params_with_formatted_birthdate
if !Dossier.find(@facade.dossier.id).update_attributes update_params_with_formatted_birthdate
flash.alert = @facade.dossier.errors.full_messages
return redirect_to users_dossier_path(id: @facade.dossier.id)
@ -174,7 +174,7 @@ class Users::DossiersController < UsersController
private
def check_siret
errors_valid_siret unless Siret.new(siret: siret).valid?
errors_valid_siret if !Siret.new(siret: siret).valid?
end
def errors_valid_siret

View file

@ -3,7 +3,7 @@ class Users::SessionsController < Sessions::SessionsController
# GET /resource/sign_in
def new
unless user_return_to_procedure_id.nil? # WTF ?
if user_return_to_procedure_id.present? # WTF ?
@dossier = Dossier.new(procedure: Procedure.active(user_return_to_procedure_id))
end

View file

@ -16,7 +16,7 @@ class UsersController < ApplicationController
end
def authorized_routes? controller
redirect_to_root_path 'Le statut de votre dossier n\'autorise pas cette URL' unless UserRoutesAuthorizationService.authorized_route?(
redirect_to_root_path 'Le statut de votre dossier n\'autorise pas cette URL' if !UserRoutesAuthorizationService.authorized_route?(
controller,
current_user_dossier)
rescue ActiveRecord::RecordNotFound

View file

@ -2,7 +2,7 @@ class ProcedureDecorator < Draper::Decorator
delegate_all
def lien
h.commencer_url(procedure_path: path) unless path.nil?
h.commencer_url(procedure_path: path) if path.present?
end
def created_at_fr

View file

@ -18,7 +18,7 @@ class DossierFacades
end
def entreprise
@dossier.entreprise.decorate unless @dossier.entreprise.nil? || @dossier.entreprise.siren.blank?
@dossier.entreprise.decorate if @dossier.entreprise.present? && @dossier.entreprise.siren.present?
end
def etablissement

View file

@ -46,7 +46,7 @@ class DossiersListFacades
end
def active_filter? preference
return true if @procedure.nil? || preference.table != 'champs' || (preference.table == 'champs' && !preference.filter.blank?)
return true if @procedure.nil? || preference.table != 'champs' || (preference.table == 'champs' && preference.filter.present?)
preference_list_dossiers_filter.where(table: :champs).where.not(filter: '').size == 0
end

View file

@ -8,7 +8,7 @@ class FileSizeValidator < ActiveModel::EachValidator
def initialize(options)
if range = (options.delete(:in) || options.delete(:within))
raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range)
raise ArgumentError, ":in and :within must be a Range" if !range.is_a?(Range)
options[:minimum], options[:maximum] = range.begin, range.end
options[:maximum] -= 1 if range.exclude_end?
end
@ -26,19 +26,19 @@ class FileSizeValidator < ActiveModel::EachValidator
keys.each do |key|
value = options[key]
unless (value.is_a?(Integer) && value >= 0) || value.is_a?(Symbol)
if !(value.is_a?(Integer) && value >= 0) && !value.is_a?(Symbol)
raise ArgumentError, ":#{key} must be a nonnegative Integer or symbol"
end
end
end
def validate_each(record, attribute, value)
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") if !value.kind_of? CarrierWave::Uploader::Base
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
CHECKS.each do |key, validity_check|
next unless check_value = options[key]
next if !check_value = options[key]
check_value =
case check_value

View file

@ -33,7 +33,9 @@ class SIADE::EtablissementAdapter
def adresse
adresse = ''
[:l1, :l2, :l3, :l4, :l5, :l6, :l7].each do |line|
adresse = adresse + data_source[:etablissement][:adresse][line] + "\r\n" unless data_source[:etablissement][:adresse][line].nil?
if data_source[:etablissement][:adresse][line].present?
adresse = adresse + data_source[:etablissement][:adresse][line] + "\r\n"
end
end
adresse
end

View file

@ -2,7 +2,7 @@ class InviteMailer < ApplicationMailer
def invite_user invite
vars_mailer invite
send_mail invite.email, "TPS - Participez à l'élaboration d'un dossier", invite.email_sender unless invite.user.nil?
send_mail invite.email, "TPS - Participez à l'élaboration d'un dossier", invite.email_sender if invite.user.present?
end
def invite_guest invite

View file

@ -24,7 +24,7 @@ class Administrateur < ActiveRecord::Base
def generate_api_token
loop do
token = SecureRandom.hex(20)
break token unless Administrateur.find_by(api_token: token)
break token if !Administrateur.find_by(api_token: token)
end
end
end

View file

@ -5,14 +5,14 @@ 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?
end
def content_url
unless content.url.nil?
if content.url.present?
if Features.remote_storage
(RemoteDownloader.new content.filename).url
else
@ -24,7 +24,7 @@ class Cerfa < ActiveRecord::Base
private
def internal_notification
unless dossier.state == 'brouillon'
if dossier.state != 'brouillon'
NotificationService.new('cerfa', self.dossier.id).notify
end
end

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

@ -167,7 +167,7 @@ class Dossier < ActiveRecord::Base
end
def export_entreprise_data
unless entreprise.nil?
if entreprise.present?
etablissement_attr = EtablissementCsvSerializer.new(self.etablissement).attributes.map { |k, v| ["etablissement.#{k}".parameterize.underscore.to_sym, v] }.to_h
entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.map { |k, v| ["entreprise.#{k}".parameterize.underscore.to_sym, v] }.to_h
else

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) }
@ -30,7 +30,7 @@ class PieceJustificative < ActiveRecord::Base
end
def content_url
unless content.url.nil?
if content.url.present?
if Features.remote_storage
(RemoteDownloader.new content.filename).url
else
@ -59,7 +59,7 @@ class PieceJustificative < ActiveRecord::Base
private
def internal_notification
unless self.type_de_piece_justificative.nil? && dossier.state == 'brouillon'
if self.type_de_piece_justificative.present? || dossier.state != 'brouillon'
NotificationService.new('piece_justificative', self.dossier.id, self.libelle).notify
end
end

View file

@ -25,7 +25,7 @@ class PreferenceListDossier < ActiveRecord::Base
columns = columns.merge({
champs: columns_champs_procedure(procedure_id),
champs_private: columns_champs_private_procedure(procedure_id)
}) unless procedure_id.nil?
}) if procedure_id.present?
columns
end

View file

@ -49,7 +49,7 @@ class Procedure < ActiveRecord::Base
end
def path
procedure_path.path unless procedure_path.nil?
procedure_path.path if procedure_path.present?
end
def default_path

View file

@ -38,7 +38,7 @@ class Search < ActiveRecord::Base
belongs_to :dossier
def results
unless @query.present?
if @query.blank?
return Search.none
end

View file

@ -10,6 +10,6 @@ class Siret
before_validation :remove_whitespace
def remove_whitespace
siret.delete!(' ') unless siret.nil?
siret.delete!(' ') if siret.present?
end
end

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

@ -18,8 +18,8 @@ class AccompagnateurService
end
def build_default_column
return unless @to == ASSIGN
return unless PreferenceListDossier.where(gestionnaire: @accompagnateur, procedure: @procedure).empty?
return if @to != ASSIGN
return if PreferenceListDossier.where(gestionnaire: @accompagnateur, procedure: @procedure).present?
@accompagnateur.build_default_preferences_list_dossier @procedure.id
end

View file

@ -40,7 +40,7 @@ class DossierService
private
def mandataire_social? mandataires_list
unless @france_connect_information.nil?
if @france_connect_information.present?
mandataires_list.each do |mandataire|
return true if mandataire[:nom].casecmp(@france_connect_information.family_name).zero? &&

View file

@ -81,7 +81,7 @@ class DossiersListGestionnaireService
pref = current_preference_smart_listing_page
if pref
unless pref.liste == @liste && pref.procedure == @procedure
if pref.liste != @liste || pref.procedure != @procedure
pref.liste = @liste
pref.procedure = @procedure
@ -91,7 +91,7 @@ class DossiersListGestionnaireService
end
end
unless new_page.nil?
if new_page.present?
pref.page = new_page
pref.save
end
@ -112,7 +112,7 @@ class DossiersListGestionnaireService
preference = @current_devise_profil.preference_list_dossiers
.find_by(table: table, attr: attr, procedure: @procedure)
preference.update order: order unless (preference.nil?)
preference.update order: order if preference.present?
end
def reset_sort!
@ -124,16 +124,16 @@ class DossiersListGestionnaireService
def joins_filter
filter_preference_list.inject([]) do |acc, preference|
acc.push(preference.table.to_sym) unless preference.table.blank? || preference.filter.blank?
acc.push(preference.table.to_sym) if preference.table.present? && preference.filter.present?
acc
end
end
def where_filter
filter_preference_list.inject('') do |acc, preference|
unless preference.filter.blank?
if preference.filter.present?
filter = preference.filter.tr('*', '%').gsub("'", "''")
filter = "%" + filter + "%" unless filter.include? '%'
filter = "%" + filter + "%" if !filter.include? '%'
value = preference.table_with_s_attr

View file

@ -2,7 +2,7 @@ class FranceConnectSaltService
attr_reader :model
def initialize france_connect_information
raise 'Not a FranceConnectInformation class' unless france_connect_information.class == FranceConnectInformation
raise 'Not a FranceConnectInformation class' if france_connect_information.class != FranceConnectInformation
@model = france_connect_information
end

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

@ -7,28 +7,28 @@ class SyncCredentialsService
end
def change_credentials!
unless @klass == User
if @klass != User
user = User.find_by(email: @email_was)
if user
return false unless user.update_columns(
return false if !user.update_columns(
email: @email,
encrypted_password: @encrypted_password)
end
end
unless @klass == Gestionnaire
if @klass != Gestionnaire
gestionnaire = Gestionnaire.find_by(email: @email_was)
if gestionnaire
return false unless gestionnaire.update_columns(
return false if !gestionnaire.update_columns(
email: @email,
encrypted_password: @encrypted_password)
end
end
unless @klass == Administrateur
if @klass != Administrateur
administrateur = Administrateur.find_by(email: @email_was)
if administrateur
return false unless administrateur.update_columns(
return false if !administrateur.update_columns(
email: @email,
encrypted_password: @encrypted_password)
end

View file

@ -13,7 +13,7 @@ class AttestationTemplateLogoUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
unless Features.remote_storage
if !Features.remote_storage
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -13,7 +13,7 @@ class AttestationTemplateSignatureUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
unless Features.remote_storage
if !Features.remote_storage
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -13,7 +13,7 @@ class AttestationUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
unless Features.remote_storage
if !Features.remote_storage
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -11,7 +11,7 @@ class CerfaUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
unless Features.remote_storage
if !Features.remote_storage
"./uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -27,11 +27,11 @@ class LocalDownloader
self.random_folder_name = SecureRandom.hex
base_path = File.join(BASE_PATH_DISK, self.random_folder_name)
unless File.directory?(BASE_PATH_DISK)
if !File.directory?(BASE_PATH_DISK)
Dir.mkdir(BASE_PATH_DISK)
end
unless File.directory?(base_path)
if !File.directory?(base_path)
Dir.mkdir(base_path)
break base_path
end

View file

@ -11,7 +11,7 @@ class PieceJustificativeUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
unless Features.remote_storage
if !Features.remote_storage
"./uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -13,7 +13,7 @@ class ProcedureLogoUploader < BaseUploader
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
unless Features.remote_storage
if !Features.remote_storage
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end

View file

@ -5,6 +5,6 @@ class EmailFormatValidator < ActiveModel::Validator
def validate(record)
return if record.email.blank?
record.errors[:base] << "Email invalide" unless email_regex.match(record.email)
record.errors[:base] << "Email invalide" if !email_regex.match(record.email)
end
end

View file

@ -5,6 +5,6 @@ class ProcedurePathFormatValidator < ActiveModel::Validator
def validate(record)
return false if record.path.blank?
record.errors[:path] << "Path invalide" unless path_regex.match(record.path)
record.errors[:path] << "Path invalide" if !path_regex.match(record.path)
end
end

View file

@ -1,9 +1,9 @@
class SiretFormatValidator < ActiveModel::EachValidator
def validate_each(record,attribute,value)
unless value =~ /^\d{14}$/
if !(value =~ /^\d{14}$/)
record.errors.add(attribute, :format)
end
unless value != nil && (luhn_checksum(value) % 10 == 0)
if value.nil? || (luhn_checksum(value) % 10 != 0)
record.errors.add(attribute, :checksum)
end
end

View file

@ -1,6 +1,6 @@
.row{ style: 'height: 34px;' }
- unless smart_listing.empty?
- if smart_listing.present?
%table.table#liste-gestionnaire
%thead
%th Enlever

View file

@ -5,7 +5,7 @@
%button.btn.btn-primary{ type: :submit }
%span.fa.fa-search
- unless smart_listing.empty?
- if smart_listing.present?
%table.table#liste-gestionnaire
%thead

View file

@ -1,4 +1,4 @@
- unless smart_listing.empty?
- if smart_listing.present?
%table.table#liste-gestionnaire
%thead
%th#libelle= smart_listing.sortable 'Email', 'email'

View file

@ -17,7 +17,7 @@
.form-group
= ff.hidden_field :order_place, value: ff.index
= ff.hidden_field :id
- unless ff.object.id.nil?
- if ff.object.id.present?
.form-group
%br &nbsp;
= ff.object.button_up(index: ff.index, url: move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index))

View file

@ -15,7 +15,7 @@
.row
.col-md-6
%h4 Logo de la procédure
- unless @procedure.logo.blank?
- if @procedure.logo.present?
= image_tag @procedure.decorate.logo_img, { style: 'height: 40px; display: inline; margin-right: 6px;', id: 'preview_procedure_logo' }
= f.file_field :logo, accept: 'image/png, image/jpg, image/jpeg', style: 'display: inline'
@ -29,7 +29,7 @@
= f.check_box :euro_flag
Afficher le drapeau européen
- unless @procedure.locked?
- if !@procedure.locked?
.row
.col-md-6
%h4 Cartographie

View file

@ -1,4 +1,4 @@
- unless smart_listing.empty?
- if smart_listing.present?
%table.table#dossiers-list
%thead
%th#ID= smart_listing.sortable 'ID', 'id'
@ -27,7 +27,7 @@
= procedure.created_at_fr
%td
= link_to('Cloner', admin_procedure_clone_path(procedure.id), 'data-method' => :put, class: 'btn-sm btn-primary clone-btn')
- unless procedure.publiee_ou_archivee?
- if !procedure.publiee_ou_archivee?
= link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), 'data-method' => :delete, class: 'btn-sm btn-danger')
= smart_listing.paginate

View file

@ -13,7 +13,7 @@
Vous vous apprêtez à
= @procedure.archivee? ? 'republier' : 'publier'
votre procédure au public.
- unless @procedure.archivee?
- if !@procedure.archivee?
%b
Elle ne pourra plus être modifiée à l'issue de cette publication.
%br

View file

@ -104,7 +104,7 @@
%h4 Archivé
- unless @facade.dossiers_archived_total == 0
- if @facade.dossiers_archived_total != 0
%ul
- @facade.dossiers_archived_by_state_total.each do |dossier|
%li

View file

@ -32,7 +32,7 @@
= ff.hidden_field :type
= ff.hidden_field :id
- unless ff.object.id.nil?
- if ff.object.id.present?
.form-group
%br &nbsp;
= ff.object.button_up(index: ff.index, url: @types_de_champ_facade.move_up_url(ff), private: @types_de_champ_facade.private)

View file

@ -1,5 +1,5 @@
.card
- unless smart_listing.empty?
- if smart_listing.present?
%table.table
%thead
%th.col-xs-4= smart_listing.sortable 'Email', :email
@ -12,7 +12,7 @@
%td
= admin.email
%td
- unless admin.last_sign_in_at.nil?
- if admin.last_sign_in_at.present?
= time_ago_in_words(l(admin.last_sign_in_at, format: "%d/%m/%Y %H:%M UTC +02:00"))
(
= admin.last_sign_in_at.localtime.strftime('%d/%m/%Y')

View file

@ -7,7 +7,7 @@
État
- @facade_data_view.preference_list_dossiers_filter.each do |preference|
- unless preference.libelle == 'Statut' || preference.libelle == 'État'
- if preference.libelle != 'Statut' && preference.libelle != 'État'
%th{ class: "col-md-#{preference.bootstrap_lg} col-lg-#{preference.bootstrap_lg}" }
- if preference.table.to_s.include? 'champs'
= preference.libelle
@ -20,7 +20,7 @@
%th.col-xs-1.center Actions
%th.col-xs-1.center Abonnés
- unless smart_listing.empty?
- if smart_listing.present?
- smart_listing.collection.each do |dossier|
%tr.dossier-row{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: dossier.id) }
- if smart_listing.name.to_s == 'follow_dossiers'
@ -35,7 +35,7 @@
%td.col-xs-1
= dossier.decorate.display_state
- @facade_data_view.preference_list_dossiers_filter.each_with_index do |preference, index|
- unless preference.libelle == 'Statut' || preference.libelle == 'État'
- if preference.libelle != 'Statut' && preference.libelle != 'État'
%td
- if preference.table.nil? || preference.table.empty?
- value = dossier.decorate.public_send(preference.attr_decorate)

View file

@ -18,7 +18,7 @@
.col-lg-4.col-md-4.col-sm-4.col-xs-4.action
Renseigner un SIRET
- unless @facade.entreprise.nil?
- if @facade.entreprise.present?
.default-data-block
.row.show-block.infos#infos_entreprise
.header

View file

@ -1,4 +1,4 @@
- unless @facade.dossier.read_only?
- if !@facade.dossier.read_only?
- if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email))
%a#maj_carte.action{ href: "/users/dossiers/#{@facade.dossier.id}/carte" }
.col-lg-2.col-md-2.col-sm-2.col-xs-2.action

View file

@ -1,4 +1,4 @@
- unless @facade.dossier.read_only?
- if !@facade.dossier.read_only?
- if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email))
%a#maj_infos.action{ href: "/users/dossiers/#{@facade.dossier.id}/description" }
#edit-dossier.col-lg-2.col-md-2.col-sm-2.col-xs-2.action

View file

@ -1,4 +1,4 @@
- unless @facade.dossier.read_only?
- if !@facade.dossier.read_only?
- if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email))
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0
.col-lg-4.col-md-4.col-sm-4.col-xs-4.action

View file

@ -23,7 +23,7 @@
.col-xs-5.depositaire-info= @facade.individual.birthdate
.row.margin-top-20
- unless @facade.champs.nil?
- if @facade.champs.present?
- @facade.champs.each do |champ|
- next if champ.type_champ == 'explication'
- if champ.type_champ == 'header_section'
@ -37,7 +37,7 @@
.col-xs-1.comments-off
= "-"
.col-xs-5.depositaire-info{ id: "champ-#{champ.id}-value" }
- unless champ.decorate.value.blank?
- if champ.decorate.value.present?
- if champ.type_champ == 'dossier_link'
- dossier = Dossier.includes(:procedure).find_by(id: champ.decorate.value)
- if dossier
@ -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;' }
\-
@ -101,7 +101,7 @@
- else
Pièce non fournie
- unless @facade.dossier.read_only?
- if !@facade.dossier.read_only?
- if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email))
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0
.row

View file

@ -55,5 +55,5 @@
.row.split-row
.col-xs-12.split-hr
- unless @facade.entreprise.rna_information.nil?
- if @facade.entreprise.rna_information.present?
= render partial: '/dossiers/infos_rna'

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

@ -18,7 +18,7 @@
%p#description_procedure{ style: 'width: 95%;', class: (@facade.entreprise.nil? ? '' : 'mask') }
= h sanitize(@facade.procedure.description)
- unless @facade.procedure.lien_site_web.blank?
- if @facade.procedure.lien_site_web.present?
.center
%a{ href: @facade.procedure.lien_site_web, target: '_blank' }
En savoir plus ...

View file

@ -2,7 +2,7 @@
%h3
Mes informations
%br
- unless @facade.entreprise.nil?
- if @facade.entreprise.present?
.center{ style: 'margin-left: -5%;' }
Vous êtes authentifié avec le SIRET

View file

@ -36,7 +36,7 @@
%li
.header-search
= form_tag recherche_path, method: :get, class: "form" do
= text_field_tag "q", "#{@search_terms unless @search_terms.nil?}", placeholder: "Rechercher un dossier"
= text_field_tag "q", "#{@search_terms if @search_terms.present?}", placeholder: "Rechercher un dossier"
%button{ title: "Rechercher" }
= image_tag "icons/search-blue.svg"
%li

View file

@ -1,4 +1,4 @@
- unless BrowserService.recommended_browser?
- if !BrowserService.recommended_browser?
#support-navigator-banner.row
.col-xs-12
= BROWSER.value.name

View file

@ -1,6 +1,6 @@
#first-block
.en-cours
- unless @procedure.logo.blank?
- if @procedure.logo.present?
= image_tag @procedure.decorate.logo_img, style: 'width: 30px;'
%b
= @procedure.libelle
@ -22,17 +22,17 @@
.procedure-list-element{ class: ('active' if active == 'Description') }
Description
- unless @procedure.locked?
- if !@procedure.locked?
%a#onglet-champs{ :href => "#{url_for admin_procedure_types_de_champ_path(@procedure)}" }
.procedure-list-element{ class: ('active' if active == 'Champs') }
Champs
- unless @procedure.locked?
- if !@procedure.locked?
%a#onglet-pieces{ :href => "#{url_for admin_procedure_pieces_justificatives_path(@procedure)}" }
.procedure-list-element{ class: ('active' if active == 'Pieces') }
Pièces jointes
- unless @procedure.locked?
- if !@procedure.locked?
%a#onglet-private-champs{ :href => "#{url_for admin_procedure_types_de_champ_private_path(@procedure)}" }
.procedure-list-element{ class: ('active' if active == 'Annotations privées') }
Annotations privées

View file

@ -10,7 +10,7 @@
#menu-block
.split-hr-left
#procedure-list
- unless current_user.dossiers.count == 0
- if current_user.dossiers.count != 0
%a{ :href => "#{url_for users_dossiers_path(liste: 'brouillon')}", 'data-toggle' => :tooltip, title: 'Les dossiers jamais proposés à la relecture.' }
.procedure-list-element#brouillon{ class: ('active' if @liste == 'brouillon') }
Brouillons

View file

@ -4,7 +4,7 @@
#search-area
= form_tag(backoffice_dossiers_search_url, method: :get) do
.input-group
= text_field_tag('q', "#{@search_terms unless @search_terms.nil?}", id: 'q', placeholder: "Recherchez parmi tous vos dossiers", class: 'form-control')
= text_field_tag('q', "#{@search_terms if @search_terms.present?}", id: 'q', placeholder: "Recherchez parmi tous vos dossiers", class: 'form-control')
%span.input-group-btn
%button.btn.btn-default#search-button
%i.fa.fa-search

View file

@ -22,7 +22,7 @@
.dropdown-menu.dropdown-menu-right.dropdown-pannel
%h4= t('dynamics.dossiers.followers.title')
%ul
- unless @facade.followers.empty?
- if @facade.followers.present?
- @facade.followers.each do |follower|
%li= follower.email
- else
@ -31,7 +31,7 @@
%p
%b Attention, les invitations sur les dossiers vont disparaître en faveur des avis externes situés en bas de la page
%ul
- unless @facade.invites.empty?
- if @facade.invites.present?
- @facade.invites.each do |invite|
%li= invite.email
- else

View file

@ -12,14 +12,14 @@
.dropdown-menu.dropdown-menu-right.dropdown-pannel
%h4= t('dynamics.dossiers.followers.title')
%ul
- unless @facade.followers.empty?
- if @facade.followers.present?
- @facade.followers.each do |follower|
%li= follower.email
- else
= t('dynamics.dossiers.followers.empty')
%h4= t('dynamics.dossiers.invites.title')
%ul
- unless @facade.invites.empty?
- if @facade.invites.present?
- @facade.invites.each do |invite|
%li= invite.email
- else

View file

@ -2,7 +2,7 @@
- @champs = @champs_private if private
- @headers = @headers_private if private
- unless @headers.blank?
- if @headers.present?
- if @champs.first.type_champ != 'header_section'
= render partial: render_partial_url, locals: { libelle: 'Dossier', order_place: -1, champs: @champs }
- @headers.each do |header|

View file

@ -4,7 +4,7 @@
%th
Formulaire de demande ou CERFA (complété et numérisé)
%td
- unless dossier.procedure.lien_demarche.blank?
- if dossier.procedure.lien_demarche.present?
%em
Récupérer le formulaire de demande ou CERFA vierge pour mon dossier :
= link_to "Télécharger", "#{dossier.procedure.lien_demarche}", target: :blank, id: :lien_cerfa
@ -26,7 +26,7 @@
.piece-description= tpj.description
%td
- unless tpj.lien_demarche.blank?
- if tpj.lien_demarche.present?
%em
Récupérer le formulaire vierge pour mon dossier :
= link_to "Télécharger", tpj.lien_demarche, target: :blank

View file

@ -1,5 +1,5 @@
.container#description-page
- unless @dossier.procedure.lien_notice.blank?
- if @dossier.procedure.lien_notice.present?
#lien_notice_panel.row{ style: 'width: 280px; position: fixed; background-color: white; right: 5%; top: 80px; z-index: 200;' }
.panel.panel-info{ style: 'margin-bottom: 0;' }
.panel-body.center
@ -16,11 +16,11 @@
-# TODO use form_for
= form_tag(url_for({ controller: 'users/description', action: :update, dossier_id: @dossier.id }), class: 'form', method: 'POST', multipart: true) do
- unless @champs.nil?
- if @champs.present?
#liste-champs
= render partial: 'users/description/champs', locals: { private: false }
- if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
- if @procedure.lien_demarche.present? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
%br
%h3 Pièces jointes
@ -32,7 +32,7 @@
-# WTF ?
- route = Rails.application.routes.recognize_path(request.referrer)
- unless route[:controller].match('admin')
- if !route[:controller].match('admin')
%div{ style: 'text-align: right;' }
%h6 Tous les champs portant un * sont obligatoires.

View file

@ -1,7 +1,7 @@
%input.form-control{ name: "champs['#{champ.id}']",
placeholder: champ.libelle,
id: "champs_#{champ.id}",
value: (champ.value.split(/[ ][0-9]*:[0-9]*/).first unless champ.value.nil?),
value: (champ.value.split(/[ ][0-9]*:[0-9]*/).first if champ.value.present?),
type: champ.type_champ,
'data-provide' => champ.data_provide,
'data-date-format' => champ.data_date_format }

View file

@ -58,6 +58,6 @@
type: champ.type_champ }
- unless champ.description.empty?
%div{ id: "description_champs_#{champ.id}", class: ('help-block' unless champ.type_champ == 'engagement') }
- if champ.description.present?
%div{ id: "description_champs_#{champ.id}", class: ('help-block' if champ.type_champ != 'engagement') }
= simple_format(sanitize(champ.description_with_links, attributes: %w(href target)))

View file

@ -1,4 +1,4 @@
- unless smart_listing.empty?
- if smart_listing.present?
%table#dossiers-list.table
%thead
%th#sort-id.col-md-1.col-lg-1.col-sm-1.col-xs-1= smart_listing.sortable 'Numéro', 'id'
@ -14,9 +14,9 @@
- else
- dossier = dossier.decorate
- dossier_url = users_dossiers_invite_path(id: invite.id) unless invite.nil?
- dossier_url = users_dossiers_invite_path(id: invite.id) if invite.present?
- if invite.nil?
- dossier_url = users_dossier_recapitulatif_path(dossier) unless dossier.brouillon?
- dossier_url = users_dossier_recapitulatif_path(dossier) if !dossier.brouillon?
- dossier_url = users_dossier_description_path(dossier) if dossier.brouillon?
%tr{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => dossier_url }

View file

@ -1,7 +1,7 @@
.two-columns.auth
.columns-container
.column.preview
- unless @dossier
- if !@dossier
= image_tag "landing/hero/dematerialiser.svg", class: "paperless-logo"
.baseline.center
%h3 Un outil simple

View file

@ -19,7 +19,7 @@ chdir APP_ROOT do
system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# if !File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end

View file

@ -11,7 +11,7 @@ require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# branch - Branch name to deploy. (needed by mina/git)
ENV['to'] ||= "staging"
raise "Bad to=#{+ENV['to']}" unless ["staging", "production"].include?(ENV['to'])
raise "Bad to=#{+ENV['to']}" if !["staging", "production"].include?(ENV['to'])
raise "missing domain, run with 'rake deploy domain=37.187.154.237'" if ENV['domain'].nil?

View file

@ -2,7 +2,7 @@ class LinkTypePieceJointeToFormulaire < ActiveRecord::Migration
# def up
# TypePieceJointe.find_each do |type_piece_jointe|
# forms = Formulaire.find_by_demarche_id(type_piece_jointe.CERFA)
# type_piece_jointe.update_attributes(formulaire_id: forms.id) unless forms.nil?
# type_piece_jointe.update_attributes(formulaire_id: forms.id) if forms.present?
# end
# end
end

View file

@ -24,7 +24,7 @@ class CreateFranceConnectInformation < ActiveRecord::Migration
birthdate: user.birthdate,
birthplace: user.birthplace,
france_connect_particulier_id: user.france_connect_particulier_id,
user_id: user.id}) unless user.france_connect_particulier_id.nil?
user_id: user.id}) if user.france_connect_particulier_id.present?
end
remove_column :users, :gender

View file

@ -33,7 +33,7 @@ class BuildDefaultPrefListDossierProcedure < ActiveRecord::Migration
base_object = gestionnaire.preference_list_dossiers.where(procedure: nil).size
created_object = gestionnaire.preference_list_dossiers.where(procedure: procedure).size
raise "ERROR nb object (#{base_object} != #{created_object})" unless created_object == base_object
raise "ERROR nb object (#{base_object} != #{created_object})" if created_object != base_object
end
end
end

View file

@ -25,7 +25,7 @@ namespace :cloudstorage do
[Cerfa, PieceJustificative, Procedure].each { |c|
c.all.each { |entry|
content = (c == Procedure) ? entry.logo : entry.content
unless content.current_path.nil? || File.exist?(File.dirname(content.current_path) + '/uploaded')
if !(content.current_path.nil? || File.exist?(File.dirname(content.current_path) + '/uploaded'))
secure_token = SecureRandom.uuid
filename = "#{entry.class.to_s.underscore}-#{secure_token}#{File.extname(content.current_path)}"
puts "Uploading #{content.current_path}"
@ -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
@ -70,7 +70,7 @@ namespace :cloudstorage do
[Cerfa, PieceJustificative, Procedure].each { |c|
c.all.each { |entry|
content = (c == Procedure) ? entry.logo : entry.content
unless content.current_path.nil?
if content.current_path.present?
if File.exist?(File.dirname(content.current_path) + '/uploaded')
previous_filename = File.read(File.dirname(content.current_path) + '/uploaded')
@ -105,7 +105,7 @@ namespace :cloudstorage do
@cont.objects_detail.each { |object, details|
last_modified = DateTime.parse(details[:last_modified])
@cont.delete_object(object) unless last_modified.utc > (Time.now - 2.year).utc
@cont.delete_object(object) if last_modified.utc <= (Time.now - 2.year).utc
}
end
end

View file

@ -3,19 +3,19 @@ FactoryGirl.define do
introduction 'Bonjour, merci de me donner votre avis sur ce dossier'
before(:create) do |avis, _evaluator|
unless avis.gestionnaire
if !avis.gestionnaire
avis.gestionnaire = create :gestionnaire
end
end
before(:create) do |avis, _evaluator|
unless avis.dossier
if !avis.dossier
avis.dossier = create :dossier
end
end
before(:create) do |avis, _evaluator|
unless avis.claimant
if !avis.claimant
avis.claimant = create :gestionnaire
end
end

View file

@ -3,7 +3,7 @@ FactoryGirl.define do
body 'plop'
before(:create) do |commentaire, _evaluator|
unless commentaire.dossier
if !commentaire.dossier
commentaire.dossier = create :dossier
end
end

View file

@ -4,7 +4,7 @@ FactoryGirl.define do
association :user, factory: [:user]
before(:create) do |dossier, _evaluator|
unless dossier.procedure
if !dossier.procedure
procedure = create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private)
dossier.procedure = procedure
end

View file

@ -7,7 +7,7 @@ FactoryGirl.define do
invite.dossier = create(:dossier)
end
unless invite.user.nil?
if invite.user.present?
invite.email = invite.user.email
end
end

View file

@ -7,7 +7,7 @@ FactoryGirl.define do
invite.dossier = create(:dossier)
end
unless invite.user.nil?
if invite.user.present?
invite.email = invite.user.email
end
end

View file

@ -4,7 +4,7 @@ FactoryGirl.define do
liste []
before(:create) do |notification, _evaluator|
unless notification.dossier
if !notification.dossier
notification.dossier = create :dossier
end
end

View file

@ -57,7 +57,7 @@ end
DatabaseCleaner.strategy = :transaction
SIADETOKEN = :valid_token unless defined? SIADETOKEN
SIADETOKEN = :valid_token if !defined? SIADETOKEN
BROWSER.value = Browser.new('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)')
include Warden::Test::Helpers