Create virus scan model to store clamav result
This commit is contained in:
parent
645d112f5c
commit
927cd3c6f4
4 changed files with 40 additions and 0 deletions
|
@ -3,6 +3,7 @@ class Champ < ApplicationRecord
|
|||
belongs_to :type_de_champ, inverse_of: :champ
|
||||
has_many :commentaires
|
||||
has_one_attached :piece_justificative_file
|
||||
has_one :virus_scan
|
||||
|
||||
delegate :libelle, :type_champ, :order_place, :mandatory?, :description, :drop_down_list, to: :type_de_champ
|
||||
|
||||
|
|
17
app/models/virus_scan.rb
Normal file
17
app/models/virus_scan.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class VirusScan < ApplicationRecord
|
||||
belongs_to :champ
|
||||
|
||||
enum status: {
|
||||
pending: 'pending',
|
||||
safe: 'safe',
|
||||
infected: 'infected',
|
||||
}
|
||||
|
||||
validates :champ_id, uniqueness: { scope: :blob_key }
|
||||
|
||||
after_create :perform_scan
|
||||
|
||||
def perform_scan
|
||||
AntiVirusJob.perform_later(self)
|
||||
end
|
||||
end
|
12
db/migrate/20180511124302_create_virus_scans.rb
Normal file
12
db/migrate/20180511124302_create_virus_scans.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class CreateVirusScans < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :virus_scans do |t|
|
||||
t.datetime :scanned_at
|
||||
t.string :status
|
||||
t.references :champ, index: true
|
||||
t.string :blob_key
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -594,6 +594,16 @@ ActiveRecord::Schema.define(version: 2018_06_01_084546) do
|
|||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
end
|
||||
|
||||
create_table "virus_scans", force: :cascade do |t|
|
||||
t.datetime "scanned_at"
|
||||
t.string "status"
|
||||
t.bigint "champ_id"
|
||||
t.string "blob_key"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["champ_id"], name: "index_virus_scans_on_champ_id"
|
||||
end
|
||||
|
||||
create_table "without_continuation_mails", id: :serial, force: :cascade do |t|
|
||||
t.text "body"
|
||||
t.string "subject"
|
||||
|
|
Loading…
Reference in a new issue