Remove deprecated virus_scan model
This commit is contained in:
parent
7b835f01fd
commit
91f2d7d706
11 changed files with 10 additions and 75 deletions
|
@ -37,27 +37,6 @@ class Avis < ApplicationRecord
|
|||
Avis.find_by(id: avis_id)&.email == email
|
||||
end
|
||||
|
||||
# FIXME remove this after migrating virus_scan to blob metadata
|
||||
def virus_scan
|
||||
VirusScan.find_by(blob_key: piece_justificative_file.blob.key)
|
||||
end
|
||||
|
||||
def virus_scan_safe?
|
||||
virus_scan&.safe? || piece_justificative_file.virus_scanner.safe?
|
||||
end
|
||||
|
||||
def virus_scan_infected?
|
||||
virus_scan&.infected? || piece_justificative_file.virus_scanner.infected?
|
||||
end
|
||||
|
||||
def virus_scan_pending?
|
||||
virus_scan&.pending? || piece_justificative_file.virus_scanner.pending?
|
||||
end
|
||||
|
||||
def virus_scan_no_scan?
|
||||
virus_scan.blank? && !piece_justificative_file.virus_scanner.analyzed?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def notify_gestionnaire
|
||||
|
|
|
@ -4,7 +4,6 @@ class Champ < ApplicationRecord
|
|||
belongs_to :parent, class_name: 'Champ'
|
||||
has_many :commentaires
|
||||
has_one_attached :piece_justificative_file
|
||||
has_one :virus_scan
|
||||
|
||||
# We declare champ specific relationships (Champs::CarteChamp and Champs::SiretChamp)
|
||||
# here because otherwise we can't easily use includes in our queries.
|
||||
|
|
|
@ -46,25 +46,8 @@ class Champs::PieceJustificativeChamp < Champ
|
|||
errors
|
||||
end
|
||||
|
||||
# FIXME remove this after migrating virus_scan to blob metadata
|
||||
def virus_scan_safe?
|
||||
virus_scan&.safe? || piece_justificative_file.virus_scanner.safe?
|
||||
end
|
||||
|
||||
def virus_scan_infected?
|
||||
virus_scan&.infected? || piece_justificative_file.virus_scanner.infected?
|
||||
end
|
||||
|
||||
def virus_scan_pending?
|
||||
virus_scan&.pending? || piece_justificative_file.virus_scanner.pending?
|
||||
end
|
||||
|
||||
def virus_scan_no_scan?
|
||||
virus_scan.blank? && !piece_justificative_file.virus_scanner.analyzed?
|
||||
end
|
||||
|
||||
def for_api
|
||||
if piece_justificative_file.attached? && (virus_scan_safe? || virus_scan_pending?)
|
||||
if piece_justificative_file.attached? && (piece_justificative_file.virus_scanner.safe? || piece_justificative_file.virus_scanner.pending?)
|
||||
Rails.application.routes.url_helpers.url_for(piece_justificative_file)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
class VirusScan < ApplicationRecord
|
||||
belongs_to :champ
|
||||
|
||||
enum status: {
|
||||
pending: 'pending',
|
||||
safe: 'safe',
|
||||
infected: 'infected'
|
||||
}
|
||||
end
|
|
@ -28,6 +28,6 @@
|
|||
Réponse donnée le #{l(avis.updated_at, format: '%d/%m/%y à %H:%M')}
|
||||
- else
|
||||
%span.waiting En attente de réponse
|
||||
= render partial: 'shared/piece_jointe/pj_link', locals: { object: avis, pj: avis.piece_justificative_file }
|
||||
= render partial: 'shared/piece_jointe/pj_link', locals: { pj: avis.piece_justificative_file, user_can_upload: false }
|
||||
.answer-body
|
||||
= simple_format(avis.answer)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
- pj = champ.piece_justificative_file
|
||||
- if pj.attached?
|
||||
= render partial: "shared/piece_jointe/pj_link", locals: { object: champ, pj: pj, user_can_upload: false }
|
||||
= render partial: "shared/piece_jointe/pj_link", locals: { pj: pj, user_can_upload: false }
|
||||
- else
|
||||
Pièce justificative non fournie
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
- if pj.attached?
|
||||
.piece-justificative-actions{ id: "piece_justificative_#{champ.id}" }
|
||||
.piece-justificative-action
|
||||
= render partial: "shared/piece_jointe/pj_link", locals: { object: champ, pj: champ.piece_justificative_file, user_can_upload: true }
|
||||
= render partial: "shared/piece_jointe/pj_link", locals: { pj: pj, user_can_upload: true }
|
||||
.piece-justificative-action
|
||||
- if champ.private?
|
||||
= link_to 'Supprimer', gestionnaire_champ_purge_champ_piece_justificative_path(procedure_id: champ.dossier.procedure_id, dossier_id: champ.dossier_id, champ_id: champ.id), remote: true, method: :delete, class: 'button small danger'
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
- if pj.attached?
|
||||
.pj-link
|
||||
- if object.virus_scan_safe? || object.virus_scan_no_scan?
|
||||
- if pj.virus_scanner.safe? || !pj.virus_scanner.analyzed?
|
||||
= link_to url_for(pj), target: '_blank', rel: 'noopener', title: "Télécharger la pièce jointe" do
|
||||
%span.icon.attachment
|
||||
= pj.filename.to_s
|
||||
- if object.virus_scan_no_scan?
|
||||
- if !pj.virus_scanner.analyzed?
|
||||
(ce fichier n’a pas été analysé par notre antivirus, téléchargez-le avec précaution)
|
||||
|
||||
- else
|
||||
= pj.filename.to_s
|
||||
- if object.virus_scan_pending?
|
||||
- if pj.virus_scanner.pending?
|
||||
(analyse antivirus en cours
|
||||
= link_to "rafraichir", request.path
|
||||
)
|
||||
- elsif object.virus_scan_infected?
|
||||
- elsif pj.virus_scanner.infected?
|
||||
- if user_can_upload
|
||||
(virus détecté, merci d’envoyer un autre fichier)
|
||||
- else
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
- if pj.attached?
|
||||
.piece-justificative-actions{ id: "piece_justificative_#{object.id}" }
|
||||
.piece-justificative-action
|
||||
= render partial: "shared/piece_jointe/pj_link", locals: { object: object, pj: object.piece_justificative_file, user_can_upload: true }
|
||||
= render partial: "shared/piece_jointe/pj_link", locals: { pj: pj, user_can_upload: true }
|
||||
.piece-justificative-action
|
||||
= button_tag 'Remplacer', type: 'button', class: 'button small', data: { 'toggle-target': "#champs_#{object.id}" }
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
FactoryBot.define do
|
||||
factory :virus_scan do
|
||||
add_attribute(:status) { VirusScan.statuses.fetch(:pending) }
|
||||
|
||||
trait :pending do
|
||||
add_attribute(:status) { VirusScan.statuses.fetch(:pending) }
|
||||
end
|
||||
|
||||
trait :safe do
|
||||
add_attribute(:status) { VirusScan.statuses.fetch(:safe) }
|
||||
end
|
||||
|
||||
trait :infected do
|
||||
add_attribute(:status) { VirusScan.statuses.fetch(:infected) }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,7 +8,7 @@ describe 'shared/piece_jointe/_pj_link.html.haml', type: :view do
|
|||
champ.piece_justificative_file.blob.update(metadata: champ.piece_justificative_file.blob.metadata.merge(virus_scan_result: virus_scan_result))
|
||||
end
|
||||
|
||||
subject { render 'shared/piece_jointe/pj_link', object: champ, pj: champ.piece_justificative_file, user_can_upload: false }
|
||||
subject { render 'shared/piece_jointe/pj_link', pj: champ.piece_justificative_file, user_can_upload: false }
|
||||
|
||||
context 'when there is no anti-virus scan' do
|
||||
let(:virus_scan_result) { nil }
|
||||
|
|
Loading…
Reference in a new issue