2018-07-25 05:30:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-22 14:49:16 -05:00
|
|
|
class Appearance < ActiveRecord::Base
|
2018-05-04 13:23:50 -04:00
|
|
|
include CacheableAttributes
|
2016-10-06 17:17:11 -04:00
|
|
|
include CacheMarkdownField
|
2018-02-21 11:43:21 -05:00
|
|
|
include ObjectStorage::BackgroundMove
|
2018-05-07 09:49:32 -04:00
|
|
|
include WithUploads
|
2016-10-06 17:17:11 -04:00
|
|
|
|
|
|
|
cache_markdown_field :description
|
2017-11-22 08:48:38 -05:00
|
|
|
cache_markdown_field :new_project_guidelines
|
2016-10-06 17:17:11 -04:00
|
|
|
|
2016-02-22 14:49:16 -05:00
|
|
|
validates :logo, file_size: { maximum: 1.megabyte }
|
|
|
|
validates :header_logo, file_size: { maximum: 1.megabyte }
|
|
|
|
|
2017-08-09 10:41:51 -04:00
|
|
|
validate :single_appearance_row, on: :create
|
|
|
|
|
2016-02-22 14:49:16 -05:00
|
|
|
mount_uploader :logo, AttachmentUploader
|
|
|
|
mount_uploader :header_logo, AttachmentUploader
|
2017-09-26 03:54:32 -04:00
|
|
|
mount_uploader :favicon, FaviconUploader
|
2018-02-02 08:59:43 -05:00
|
|
|
|
2018-05-04 13:23:50 -04:00
|
|
|
# Overrides CacheableAttributes.current_without_cache
|
|
|
|
def self.current_without_cache
|
|
|
|
first
|
2017-08-09 10:41:51 -04: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 14:49:16 -05:00
|
|
|
end
|