commit
766f0401db
5 changed files with 8 additions and 11 deletions
|
@ -61,7 +61,7 @@ class Admin::GestionnairesController < AdminController
|
|||
end
|
||||
|
||||
def assign_gestionnaire!
|
||||
if current_administrateur.gestionnaires.include? @gestionnaire
|
||||
if current_administrateur.gestionnaires.include?(@gestionnaire)
|
||||
flash.alert = 'Instructeur déjà ajouté'
|
||||
else
|
||||
@gestionnaire.administrateurs.push current_administrateur
|
||||
|
|
|
@ -41,7 +41,7 @@ class FileSizeValidator < ActiveModel::EachValidator
|
|||
end
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
if !value.kind_of? CarrierWave::Uploader::Base
|
||||
if !value.kind_of?(CarrierWave::Uploader::Base)
|
||||
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected")
|
||||
end
|
||||
|
||||
|
|
|
@ -30,8 +30,9 @@ class User < ApplicationRecord
|
|||
|
||||
def self.find_for_france_connect(email, siret)
|
||||
user = User.find_by(email: email)
|
||||
|
||||
if user.nil?
|
||||
return User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret)
|
||||
User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret)
|
||||
else
|
||||
user.update(siret: siret)
|
||||
user
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
class ClamavService
|
||||
def self.safe_file?(file_path)
|
||||
if Rails.env == 'development'
|
||||
if Rails.env.development?
|
||||
return true
|
||||
end
|
||||
|
||||
FileUtils.chmod 0666, file_path
|
||||
FileUtils.chmod(0666, file_path)
|
||||
|
||||
client = ClamAV::Client.new
|
||||
response = client.execute(ClamAV::Commands::ScanCommand.new(file_path))
|
||||
|
||||
if response.first.class == ClamAV::VirusResponse
|
||||
return false
|
||||
end
|
||||
|
||||
true
|
||||
response.first.class != ClamAV::VirusResponse
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ class PiecesJustificativesService
|
|||
|
||||
def self.upload_one!(dossier, user, params)
|
||||
content = params[:piece_justificative][:content]
|
||||
if ClamavService.safe_file? content.path
|
||||
if ClamavService.safe_file?(content.path)
|
||||
pj = PieceJustificative.new(content: content,
|
||||
dossier: dossier,
|
||||
type_de_piece_justificative: nil,
|
||||
|
|
Loading…
Reference in a new issue