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 Enabled: false
Rails/Present: Rails/Present:
Enabled: false Enabled: true
Rails/ReadWriteAttribute: Rails/ReadWriteAttribute:
Enabled: false Enabled: false
@ -1029,7 +1029,7 @@ Style/TrivialAccessors:
Enabled: false Enabled: false
Style/UnlessElse: Style/UnlessElse:
Enabled: false Enabled: true
Style/UnneededCapitalW: Style/UnneededCapitalW:
Enabled: false Enabled: false

View file

@ -11,7 +11,7 @@ class Admin::ChangeDossierStateController < AdminController
def check def check
@dossier = Dossier.find(params[:dossier][:id]) @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' flash.alert = 'Dossier introuvable'
return redirect_to admin_change_dossier_state_path return redirect_to admin_change_dossier_state_path
end end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -14,11 +14,11 @@ class FranceConnect::ParticulierController < ApplicationController
end end
def callback 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]) 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.find_by_france_connect_particulier user_infos
france_connect_information = FranceConnectInformation.create( france_connect_information = FranceConnectInformation.create(
@ -44,7 +44,7 @@ class FranceConnect::ParticulierController < ApplicationController
end end
def new 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]) france_connect_information = FranceConnectInformation.find(params[:fci_id])
@user = User.new(france_connect_information: france_connect_information).decorate @user = User.new(france_connect_information: france_connect_information).decorate
@ -53,13 +53,13 @@ class FranceConnect::ParticulierController < ApplicationController
end end
def check_email 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]) user = User.find_by_email(params[:user][:email_france_connect])
return create if user.nil? return create if user.nil?
unless params[:user][:password].nil? if params[:user][:password].present?
if user.valid_password?(params[:user][:password]) if user.valid_password?(params[:user][:password])
user.france_connect_information = FranceConnectInformation.find(params[:fci_id]) 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 = User.new email: params[:user][:email_france_connect]
user.password = Devise.friendly_token[0, 20] user.password = Devise.friendly_token[0, 20]
unless user.valid? if !user.valid?
flash.alert = 'Email non valide' 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']} 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) invite = class_var.create(dossier: dossier, user: user, email: email, email_sender: email_sender)
if invite.valid? if invite.valid?
InviteMailer.invite_user(invite).deliver_now! unless invite.user.nil? if invite.user.present?
InviteMailer.invite_guest(invite).deliver_now! if invite.user.nil? InviteMailer.invite_user(invite).deliver_now!
else
InviteMailer.invite_guest(invite).deliver_now!
end
flash.notice = "Invitation envoyée (#{invite.email})" flash.notice = "Invitation envoyée (#{invite.email})"
else else
@ -31,7 +34,9 @@ class InvitesController < ApplicationController
private private
def gestionnaire_or_user? 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_user if user_signed_in?
@current_devise_profil = current_gestionnaire if gestionnaire_signed_in? @current_devise_profil = current_gestionnaire if gestionnaire_signed_in?

View file

@ -136,13 +136,13 @@ module NewGestionnaire
def position def position
etablissement = dossier.etablissement 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" lon = "2.428462"
lat = "46.538192" lat = "46.538192"
zoom = "13" zoom = "13"
unless point.nil? if point.present?
lon = point.x.to_s lon = point.x.to_s
lat = point.y.to_s lat = point.y.to_s
end end

View file

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

View file

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

View file

@ -2,9 +2,9 @@ class Users::Dossiers::AddSiretController < ApplicationController
def show def show
@facade = DossierFacades.new params[:dossier_id], current_user.email @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 rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found') flash.alert = t('errors.messages.dossier_not_found')

View file

@ -1,7 +1,7 @@
class Users::Dossiers::InvitesController < UsersController class Users::Dossiers::InvitesController < UsersController
def authenticate_user! def authenticate_user!
session["user_return_to"] = request.fullpath 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 super
end end

View file

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

View file

@ -3,7 +3,7 @@ class Users::SessionsController < Sessions::SessionsController
# GET /resource/sign_in # GET /resource/sign_in
def new 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)) @dossier = Dossier.new(procedure: Procedure.active(user_return_to_procedure_id))
end end

View file

@ -16,7 +16,7 @@ class UsersController < ApplicationController
end end
def authorized_routes? controller 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, controller,
current_user_dossier) current_user_dossier)
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound

View file

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

View file

@ -18,7 +18,7 @@ class DossierFacades
end end
def entreprise 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 end
def etablissement def etablissement

View file

@ -46,7 +46,7 @@ class DossiersListFacades
end end
def active_filter? preference 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 preference_list_dossiers_filter.where(table: :champs).where.not(filter: '').size == 0
end end

View file

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

View file

@ -33,7 +33,9 @@ class SIADE::EtablissementAdapter
def adresse def adresse
adresse = '' adresse = ''
[:l1, :l2, :l3, :l4, :l5, :l6, :l7].each do |line| [: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 end
adresse adresse
end end

View file

@ -2,7 +2,7 @@ class InviteMailer < ApplicationMailer
def invite_user invite def invite_user invite
vars_mailer 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 end
def invite_guest invite def invite_guest invite

View file

@ -24,7 +24,7 @@ class Administrateur < ActiveRecord::Base
def generate_api_token def generate_api_token
loop do loop do
token = SecureRandom.hex(20) 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 end
end end

View file

@ -5,14 +5,14 @@ class Cerfa < ActiveRecord::Base
mount_uploader :content, CerfaUploader mount_uploader :content, CerfaUploader
validates :content, :file_size => {:maximum => 20.megabytes} 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? def empty?
content.blank? content.blank?
end end
def content_url def content_url
unless content.url.nil? if content.url.present?
if Features.remote_storage if Features.remote_storage
(RemoteDownloader.new content.filename).url (RemoteDownloader.new content.filename).url
else else
@ -24,7 +24,7 @@ class Cerfa < ActiveRecord::Base
private private
def internal_notification def internal_notification
unless dossier.state == 'brouillon' if dossier.state != 'brouillon'
NotificationService.new('cerfa', self.dossier.id).notify NotificationService.new('cerfa', self.dossier.id).notify
end end
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 :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' } 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) } scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) }
@ -39,7 +39,7 @@ class Champ < ActiveRecord::Base
end end
def same_date? num, compare def same_date? num, compare
if type_champ == 'datetime' && !value.nil? if type_champ == 'datetime' && value.present?
if value.to_datetime.strftime(compare) == num if value.to_datetime.strftime(compare) == num
return true return true
end end

View file

@ -167,7 +167,7 @@ class Dossier < ActiveRecord::Base
end end
def export_entreprise_data 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 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 entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.map { |k, v| ["entreprise.#{k}".parameterize.underscore.to_sym, v] }.to_h
else else

View file

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

View file

@ -13,7 +13,7 @@ class PieceJustificative < ActiveRecord::Base
validates :content, :file_size => {:maximum => 20.megabytes} validates :content, :file_size => {:maximum => 20.megabytes}
validates :content, presence: true, allow_blank: false, allow_nil: false 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) } scope :updated_since?, -> (date) { where('pieces_justificatives.updated_at > ?', date) }
@ -30,7 +30,7 @@ class PieceJustificative < ActiveRecord::Base
end end
def content_url def content_url
unless content.url.nil? if content.url.present?
if Features.remote_storage if Features.remote_storage
(RemoteDownloader.new content.filename).url (RemoteDownloader.new content.filename).url
else else
@ -59,7 +59,7 @@ class PieceJustificative < ActiveRecord::Base
private private
def internal_notification 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 NotificationService.new('piece_justificative', self.dossier.id, self.libelle).notify
end end
end end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -40,7 +40,7 @@ class DossierService
private private
def mandataire_social? mandataires_list def mandataire_social? mandataires_list
unless @france_connect_information.nil? if @france_connect_information.present?
mandataires_list.each do |mandataire| mandataires_list.each do |mandataire|
return true if mandataire[:nom].casecmp(@france_connect_information.family_name).zero? && 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 pref = current_preference_smart_listing_page
if pref if pref
unless pref.liste == @liste && pref.procedure == @procedure if pref.liste != @liste || pref.procedure != @procedure
pref.liste = @liste pref.liste = @liste
pref.procedure = @procedure pref.procedure = @procedure
@ -91,7 +91,7 @@ class DossiersListGestionnaireService
end end
end end
unless new_page.nil? if new_page.present?
pref.page = new_page pref.page = new_page
pref.save pref.save
end end
@ -112,7 +112,7 @@ class DossiersListGestionnaireService
preference = @current_devise_profil.preference_list_dossiers preference = @current_devise_profil.preference_list_dossiers
.find_by(table: table, attr: attr, procedure: @procedure) .find_by(table: table, attr: attr, procedure: @procedure)
preference.update order: order unless (preference.nil?) preference.update order: order if preference.present?
end end
def reset_sort! def reset_sort!
@ -124,16 +124,16 @@ class DossiersListGestionnaireService
def joins_filter def joins_filter
filter_preference_list.inject([]) do |acc, preference| 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 acc
end end
end end
def where_filter def where_filter
filter_preference_list.inject('') do |acc, preference| filter_preference_list.inject('') do |acc, preference|
unless preference.filter.blank? if preference.filter.present?
filter = preference.filter.tr('*', '%').gsub("'", "''") filter = preference.filter.tr('*', '%').gsub("'", "''")
filter = "%" + filter + "%" unless filter.include? '%' filter = "%" + filter + "%" if !filter.include? '%'
value = preference.table_with_s_attr value = preference.table_with_s_attr

View file

@ -2,7 +2,7 @@ class FranceConnectSaltService
attr_reader :model attr_reader :model
def initialize france_connect_information 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 @model = france_connect_information
end end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,6 +5,6 @@ class EmailFormatValidator < ActiveModel::Validator
def validate(record) def validate(record)
return if record.email.blank? 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
end end

View file

@ -5,6 +5,6 @@ class ProcedurePathFormatValidator < ActiveModel::Validator
def validate(record) def validate(record)
return false if record.path.blank? 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
end end

View file

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

View file

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

View file

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

View file

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

View file

@ -17,7 +17,7 @@
.form-group .form-group
= ff.hidden_field :order_place, value: ff.index = ff.hidden_field :order_place, value: ff.index
= ff.hidden_field :id = ff.hidden_field :id
- unless ff.object.id.nil? - if ff.object.id.present?
.form-group .form-group
%br &nbsp; %br &nbsp;
= ff.object.button_up(index: ff.index, url: move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) = 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 .row
.col-md-6 .col-md-6
%h4 Logo de la procédure %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' } = 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' = f.file_field :logo, accept: 'image/png, image/jpg, image/jpeg', style: 'display: inline'
@ -29,7 +29,7 @@
= f.check_box :euro_flag = f.check_box :euro_flag
Afficher le drapeau européen Afficher le drapeau européen
- unless @procedure.locked? - if !@procedure.locked?
.row .row
.col-md-6 .col-md-6
%h4 Cartographie %h4 Cartographie

View file

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

View file

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

View file

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

View file

@ -32,7 +32,7 @@
= ff.hidden_field :type = ff.hidden_field :type
= ff.hidden_field :id = ff.hidden_field :id
- unless ff.object.id.nil? - if ff.object.id.present?
.form-group .form-group
%br &nbsp; %br &nbsp;
= ff.object.button_up(index: ff.index, url: @types_de_champ_facade.move_up_url(ff), private: @types_de_champ_facade.private) = 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 .card
- unless smart_listing.empty? - if smart_listing.present?
%table.table %table.table
%thead %thead
%th.col-xs-4= smart_listing.sortable 'Email', :email %th.col-xs-4= smart_listing.sortable 'Email', :email
@ -12,7 +12,7 @@
%td %td
= admin.email = admin.email
%td %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")) = 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') = admin.last_sign_in_at.localtime.strftime('%d/%m/%Y')

View file

@ -7,7 +7,7 @@
État État
- @facade_data_view.preference_list_dossiers_filter.each do |preference| - @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}" } %th{ class: "col-md-#{preference.bootstrap_lg} col-lg-#{preference.bootstrap_lg}" }
- if preference.table.to_s.include? 'champs' - if preference.table.to_s.include? 'champs'
= preference.libelle = preference.libelle
@ -20,7 +20,7 @@
%th.col-xs-1.center Actions %th.col-xs-1.center Actions
%th.col-xs-1.center Abonnés %th.col-xs-1.center Abonnés
- unless smart_listing.empty? - if smart_listing.present?
- smart_listing.collection.each do |dossier| - smart_listing.collection.each do |dossier|
%tr.dossier-row{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: dossier.id) } %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' - if smart_listing.name.to_s == 'follow_dossiers'
@ -35,7 +35,7 @@
%td.col-xs-1 %td.col-xs-1
= dossier.decorate.display_state = dossier.decorate.display_state
- @facade_data_view.preference_list_dossiers_filter.each_with_index do |preference, index| - @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 %td
- if preference.table.nil? || preference.table.empty? - if preference.table.nil? || preference.table.empty?
- value = dossier.decorate.public_send(preference.attr_decorate) - 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 .col-lg-4.col-md-4.col-sm-4.col-xs-4.action
Renseigner un SIRET Renseigner un SIRET
- unless @facade.entreprise.nil? - if @facade.entreprise.present?
.default-data-block .default-data-block
.row.show-block.infos#infos_entreprise .row.show-block.infos#infos_entreprise
.header .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)) - 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" } %a#maj_carte.action{ href: "/users/dossiers/#{@facade.dossier.id}/carte" }
.col-lg-2.col-md-2.col-sm-2.col-xs-2.action .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 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" } %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 #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 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 - 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 .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 .col-xs-5.depositaire-info= @facade.individual.birthdate
.row.margin-top-20 .row.margin-top-20
- unless @facade.champs.nil? - if @facade.champs.present?
- @facade.champs.each do |champ| - @facade.champs.each do |champ|
- next if champ.type_champ == 'explication' - next if champ.type_champ == 'explication'
- if champ.type_champ == 'header_section' - if champ.type_champ == 'header_section'
@ -37,7 +37,7 @@
.col-xs-1.comments-off .col-xs-1.comments-off
= "-" = "-"
.col-xs-5.depositaire-info{ id: "champ-#{champ.id}-value" } .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' - if champ.type_champ == 'dossier_link'
- dossier = Dossier.includes(:procedure).find_by(id: champ.decorate.value) - dossier = Dossier.includes(:procedure).find_by(id: champ.decorate.value)
- if dossier - if dossier
@ -91,7 +91,7 @@
.col-xs-5.despositaire-info .col-xs-5.despositaire-info
- if type_de_piece_justificative.api_entreprise - if type_de_piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous. %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 %a{ href: "#{@pj.content_url}", target: '_blank' } Consulter
%span{ style: 'margin-left: 12px;' } %span{ style: 'margin-left: 12px;' }
\- \-
@ -101,7 +101,7 @@
- else - else
Pièce non fournie 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 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 - if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0
.row .row

View file

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

View file

@ -29,7 +29,7 @@
.col-xs-6 .col-xs-6
- if type_de_piece_justificative.api_entreprise - if type_de_piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous. %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? -# - if user_signed_in?
-# = 'Pièce fournie' -# = 'Pièce fournie'
-# - elsif gestionnaire_signed_in? -# - elsif gestionnaire_signed_in?

View file

@ -25,7 +25,7 @@
%td.col-lg-6.col-md-6.col-sm-6.col-xs-6 %td.col-lg-6.col-md-6.col-sm-6.col-xs-6
- if type_de_piece_justificative.api_entreprise - if type_de_piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous. %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? -# - if user_signed_in?
-# = 'Pièce fournie' -# = 'Pièce fournie'
-# - elsif gestionnaire_signed_in? -# - elsif gestionnaire_signed_in?

View file

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

View file

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

View file

@ -36,7 +36,7 @@
%li %li
.header-search .header-search
= form_tag recherche_path, method: :get, class: "form" do = 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" } %button{ title: "Rechercher" }
= image_tag "icons/search-blue.svg" = image_tag "icons/search-blue.svg"
%li %li

View file

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

View file

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

View file

@ -10,7 +10,7 @@
#menu-block #menu-block
.split-hr-left .split-hr-left
#procedure-list #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.' } %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') } .procedure-list-element#brouillon{ class: ('active' if @liste == 'brouillon') }
Brouillons Brouillons

View file

@ -4,7 +4,7 @@
#search-area #search-area
= form_tag(backoffice_dossiers_search_url, method: :get) do = form_tag(backoffice_dossiers_search_url, method: :get) do
.input-group .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 %span.input-group-btn
%button.btn.btn-default#search-button %button.btn.btn-default#search-button
%i.fa.fa-search %i.fa.fa-search

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
.container#description-page .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;' } #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.panel-info{ style: 'margin-bottom: 0;' }
.panel-body.center .panel-body.center
@ -16,11 +16,11 @@
-# TODO use form_for -# TODO use form_for
= form_tag(url_for({ controller: 'users/description', action: :update, dossier_id: @dossier.id }), class: 'form', method: 'POST', multipart: true) do = 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 #liste-champs
= render partial: 'users/description/champs', locals: { private: false } = 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 %br
%h3 Pièces jointes %h3 Pièces jointes
@ -32,7 +32,7 @@
-# WTF ? -# WTF ?
- route = Rails.application.routes.recognize_path(request.referrer) - route = Rails.application.routes.recognize_path(request.referrer)
- unless route[:controller].match('admin') - if !route[:controller].match('admin')
%div{ style: 'text-align: right;' } %div{ style: 'text-align: right;' }
%h6 Tous les champs portant un * sont obligatoires. %h6 Tous les champs portant un * sont obligatoires.

View file

@ -1,7 +1,7 @@
%input.form-control{ name: "champs['#{champ.id}']", %input.form-control{ name: "champs['#{champ.id}']",
placeholder: champ.libelle, placeholder: champ.libelle,
id: "champs_#{champ.id}", 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, type: champ.type_champ,
'data-provide' => champ.data_provide, 'data-provide' => champ.data_provide,
'data-date-format' => champ.data_date_format } 'data-date-format' => champ.data_date_format }

View file

@ -58,6 +58,6 @@
type: champ.type_champ } type: champ.type_champ }
- unless champ.description.empty? - if champ.description.present?
%div{ id: "description_champs_#{champ.id}", class: ('help-block' unless champ.type_champ == 'engagement') } %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))) = 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 %table#dossiers-list.table
%thead %thead
%th#sort-id.col-md-1.col-lg-1.col-sm-1.col-xs-1= smart_listing.sortable 'Numéro', 'id' %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 - else
- dossier = dossier.decorate - 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? - 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? - dossier_url = users_dossier_description_path(dossier) if dossier.brouillon?
%tr{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => dossier_url } %tr{ id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => dossier_url }

View file

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

View file

@ -19,7 +19,7 @@ chdir APP_ROOT do
system('bundle check') || system!('bundle install') system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files ==" # 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' # cp 'config/database.yml.sample', 'config/database.yml'
# end # 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) # branch - Branch name to deploy. (needed by mina/git)
ENV['to'] ||= "staging" 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? 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 # def up
# TypePieceJointe.find_each do |type_piece_jointe| # TypePieceJointe.find_each do |type_piece_jointe|
# forms = Formulaire.find_by_demarche_id(type_piece_jointe.CERFA) # 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 # end
end end

View file

@ -24,7 +24,7 @@ class CreateFranceConnectInformation < ActiveRecord::Migration
birthdate: user.birthdate, birthdate: user.birthdate,
birthplace: user.birthplace, birthplace: user.birthplace,
france_connect_particulier_id: user.france_connect_particulier_id, 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 end
remove_column :users, :gender remove_column :users, :gender

View file

@ -33,7 +33,7 @@ class BuildDefaultPrefListDossierProcedure < ActiveRecord::Migration
base_object = gestionnaire.preference_list_dossiers.where(procedure: nil).size base_object = gestionnaire.preference_list_dossiers.where(procedure: nil).size
created_object = gestionnaire.preference_list_dossiers.where(procedure: procedure).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 end
end end

View file

@ -25,7 +25,7 @@ namespace :cloudstorage do
[Cerfa, PieceJustificative, Procedure].each { |c| [Cerfa, PieceJustificative, Procedure].each { |c|
c.all.each { |entry| c.all.each { |entry|
content = (c == Procedure) ? entry.logo : entry.content 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 secure_token = SecureRandom.uuid
filename = "#{entry.class.to_s.underscore}-#{secure_token}#{File.extname(content.current_path)}" filename = "#{entry.class.to_s.underscore}-#{secure_token}#{File.extname(content.current_path)}"
puts "Uploading #{content.current_path}" puts "Uploading #{content.current_path}"
@ -44,7 +44,7 @@ namespace :cloudstorage do
error_count += 1 error_count += 1
end end
else 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 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 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) entry.update_column(c == Procedure ? :logo_secure_token : :content_secure_token, secure_token)
puts "RESTORE IN DATABASE: #{filename} " puts "RESTORE IN DATABASE: #{filename} "
elsif !content.current_path.nil? elsif content.current_path.present?
puts "Skipping #{content.current_path}" puts "Skipping #{content.current_path}"
end end
end end
@ -70,7 +70,7 @@ namespace :cloudstorage do
[Cerfa, PieceJustificative, Procedure].each { |c| [Cerfa, PieceJustificative, Procedure].each { |c|
c.all.each { |entry| c.all.each { |entry|
content = (c == Procedure) ? entry.logo : entry.content 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') if File.exist?(File.dirname(content.current_path) + '/uploaded')
previous_filename = File.read(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| @cont.objects_detail.each { |object, details|
last_modified = DateTime.parse(details[:last_modified]) 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
end end

View file

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

View file

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

View file

@ -4,7 +4,7 @@ FactoryGirl.define do
association :user, factory: [:user] association :user, factory: [:user]
before(:create) do |dossier, _evaluator| 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) procedure = create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private)
dossier.procedure = procedure dossier.procedure = procedure
end end

View file

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

View file

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

View file

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

View file

@ -57,7 +57,7 @@ end
DatabaseCleaner.strategy = :transaction 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)') BROWSER.value = Browser.new('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)')
include Warden::Test::Helpers include Warden::Test::Helpers