Added pdf file upload

This commit is contained in:
2024-08-01 23:15:05 +02:00
parent 69bca2d99e
commit f7a60a90d8
10 changed files with 199 additions and 31 deletions

View File

@@ -2,6 +2,10 @@ class Job < ApplicationRecord
belongs_to :operator, class_name: 'User', optional: true
belongs_to :costumer, class_name: 'User', optional: true
has_one_attached :pdf
validates_presence_of :costumer_firstname, :costumer_lastname, :privacy_policy_accepted, :pdf
# NOTE: Multiple status if paing before brinting?
enum status: {
open: 0,
@@ -32,4 +36,16 @@ class Job < ApplicationRecord
def fullname
[costumer_firstname, ' ', costumer_lastname].join
end
# TODO: Implement validation
def acceptable_pdf
return unless pdf.attached?
errors.add(:main_image, 'is too big') unless main_image.blob.byte_size <= 100.megabyte
acceptable_types = ['application/pdf']
return if acceptable_types.include?(main_image.content_type)
errors.add(:main_image, 'must be a PDF')
end
end