demarches-normaliennes/app/components/attachment/show_component.rb

29 lines
682 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Attachment::ShowComponent < ApplicationComponent
def initialize(attachment:, new_tab: false, truncate: false)
@attachment = attachment
@new_tab = new_tab
@truncate = truncate
end
attr_reader :attachment, :new_tab, :truncate
def should_display_link?
(attachment.virus_scanner.safe? || !attachment.virus_scanner.started?) && !attachment.watermark_pending?
end
def error_message
case
when attachment.virus_scanner.infected?
2022-11-22 19:25:45 +01:00
t(".errors.virus_infected")
when attachment.virus_scanner.corrupt?
2022-11-22 19:25:45 +01:00
t(".errors.corrupted_file")
end
end
def error?
attachment.virus_scanner_error?
end
end