gitlab-org--gitlab-foss/app/models/appearance.rb

32 lines
849 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Appearance < ActiveRecord::Base
include CacheableAttributes
include CacheMarkdownField
2018-02-21 11:43:21 -05:00
include ObjectStorage::BackgroundMove
2018-05-07 09:49:32 -04:00
include WithUploads
cache_markdown_field :description
cache_markdown_field :new_project_guidelines
validates :logo, file_size: { maximum: 1.megabyte }
validates :header_logo, file_size: { maximum: 1.megabyte }
validate :single_appearance_row, on: :create
mount_uploader :logo, AttachmentUploader
mount_uploader :header_logo, AttachmentUploader
mount_uploader :favicon, FaviconUploader
# Overrides CacheableAttributes.current_without_cache
def self.current_without_cache
first
end
def single_appearance_row
if self.class.any?
errors.add(:single_appearance_row, 'Only 1 appearances row can exist')
end
end
end