2018-07-25 09:30:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-22 19:49:16 +00:00
|
|
|
class Appearance < ActiveRecord::Base
|
2018-05-04 17:23:50 +00:00
|
|
|
include CacheableAttributes
|
2016-10-06 21:17:11 +00:00
|
|
|
include CacheMarkdownField
|
2018-02-21 16:43:21 +00:00
|
|
|
include ObjectStorage::BackgroundMove
|
2018-05-07 13:49:32 +00:00
|
|
|
include WithUploads
|
2016-10-06 21:17:11 +00:00
|
|
|
|
|
|
|
cache_markdown_field :description
|
2017-11-22 13:48:38 +00:00
|
|
|
cache_markdown_field :new_project_guidelines
|
2016-10-06 21:17:11 +00:00
|
|
|
|
2016-02-22 19:49:16 +00:00
|
|
|
validates :logo, file_size: { maximum: 1.megabyte }
|
|
|
|
validates :header_logo, file_size: { maximum: 1.megabyte }
|
|
|
|
|
2017-08-09 14:41:51 +00:00
|
|
|
validate :single_appearance_row, on: :create
|
|
|
|
|
2016-02-22 19:49:16 +00:00
|
|
|
mount_uploader :logo, AttachmentUploader
|
|
|
|
mount_uploader :header_logo, AttachmentUploader
|
2017-09-26 07:54:32 +00:00
|
|
|
mount_uploader :favicon, FaviconUploader
|
2018-02-02 13:59:43 +00:00
|
|
|
|
2018-05-04 17:23:50 +00:00
|
|
|
# Overrides CacheableAttributes.current_without_cache
|
|
|
|
def self.current_without_cache
|
|
|
|
first
|
2017-08-09 14:41:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def single_appearance_row
|
|
|
|
if self.class.any?
|
|
|
|
errors.add(:single_appearance_row, 'Only 1 appearances row can exist')
|
|
|
|
end
|
|
|
|
end
|
2016-02-22 19:49:16 +00:00
|
|
|
end
|