diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-21 22:28:18 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-21 22:28:18 +0200 |
| commit | 9c951f3a0f379b0f459988106cf3f839acdadbe2 (patch) | |
| tree | ad51cb1700689bfa0915a1319576412d68f66150 /app/models | |
| parent | 987c8224c7f1bafb84d5e284ff0093921b92f1a0 (diff) | |
More PDF headline eligibility
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/asset.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/asset.rb b/app/models/asset.rb index 4a295d8..8aa5415 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | class Asset < ApplicationRecord | 1 | class Asset < ApplicationRecord |
| 2 | IMAGE_CONTENT_TYPES = ["image/gif", "image/jpeg", "image/png", "image/webp"] | 2 | IMAGE_CONTENT_TYPES = ["image/gif", "image/jpeg", "image/png", "image/webp"] |
| 3 | PDF_CONTENT_TYPE = "application/pdf" | ||
| 3 | 4 | ||
| 4 | include FileAttachment | 5 | include FileAttachment |
| 5 | 6 | ||
| @@ -9,6 +10,7 @@ class Asset < ApplicationRecord | |||
| 9 | scope :images, -> { where(:upload_content_type => IMAGE_CONTENT_TYPES) } | 10 | scope :images, -> { where(:upload_content_type => IMAGE_CONTENT_TYPES) } |
| 10 | scope :documents, -> { where(:upload_content_type => ["application/pdf", "text/plain", "text/rtf"]) } | 11 | scope :documents, -> { where(:upload_content_type => ["application/pdf", "text/plain", "text/rtf"]) } |
| 11 | scope :audio, -> { where(:upload_content_type => ["audio/mpeg", "audio/x-m4a", "audio/wav", "audio/x-wav"]) } | 12 | scope :audio, -> { where(:upload_content_type => ["audio/mpeg", "audio/x-m4a", "audio/wav", "audio/x-wav"]) } |
| 13 | scope :headline_eligible, -> { where(:upload_content_type => IMAGE_CONTENT_TYPES + [PDF_CONTENT_TYPE]) } | ||
| 12 | 14 | ||
| 13 | validates :license_key, inclusion: { in: -> { AssetLicense.keys } }, allow_blank: true | 15 | validates :license_key, inclusion: { in: -> { AssetLicense.keys } }, allow_blank: true |
| 14 | 16 | ||
| @@ -16,6 +18,10 @@ class Asset < ApplicationRecord | |||
| 16 | IMAGE_CONTENT_TYPES.include?(upload_content_type) | 18 | IMAGE_CONTENT_TYPES.include?(upload_content_type) |
| 17 | end | 19 | end |
| 18 | 20 | ||
| 21 | def pdf? | ||
| 22 | upload_content_type == PDF_CONTENT_TYPE | ||
| 23 | end | ||
| 24 | |||
| 19 | def has_credit? | 25 | def has_credit? |
| 20 | creator.present? || source_url.present? || license_key.present? | 26 | creator.present? || source_url.present? || license_key.present? |
| 21 | end | 27 | end |
