commit
6f3653702f
13 changed files with 15 additions and 80 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}" }
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"debounce": "^1.2.0",
|
||||
"dom4": "^2.1.4",
|
||||
"highcharts": "^6.1.2",
|
||||
"jquery": "^3.4.0",
|
||||
"jquery": "^3.4.1",
|
||||
"leaflet": "^1.4.0",
|
||||
"leaflet-freedraw": "^2.10.0",
|
||||
"prop-types": "^15.7.2",
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -4510,10 +4510,10 @@ jquery-mousewheel@~3.1.13:
|
|||
resolved "https://registry.yarnpkg.com/jquery-mousewheel/-/jquery-mousewheel-3.1.13.tgz#06f0335f16e353a695e7206bf50503cb523a6ee5"
|
||||
integrity sha1-BvAzXxbjU6aV5yBr9QUDy1I6buU=
|
||||
|
||||
jquery@^3.4.0:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.0.tgz#8de513fa0fa4b2c7d2e48a530e26f0596936efdf"
|
||||
integrity sha512-ggRCXln9zEqv6OqAGXFEcshF5dSBvCkzj6Gm2gzuR5fWawaX8t7cxKVkkygKODrDAzKdoYw3l/e3pm3vlT4IbQ==
|
||||
jquery@^3.4.1:
|
||||
version "3.4.1"
|
||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2"
|
||||
integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==
|
||||
|
||||
js-base64@^2.1.8:
|
||||
version "2.5.1"
|
||||
|
|
Loading…
Reference in a new issue