publication/app/models/publication.rb

35 lines
1.0 KiB
Ruby
Raw Normal View History

2023-06-04 14:41:53 +00:00
class Publication
2018-10-04 02:47:23 +00:00
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitTag::Taggable
include OrbitCategory::Categorizable
include Slug
2023-07-21 02:10:22 +00:00
field :title, as: :slug_title, type: String, localize: true
2018-10-04 02:47:23 +00:00
field :pub_date, type: DateTime
field :author, type: String, localize: true
field :author_description, type: String, localize: true
2018-10-04 05:29:27 +00:00
field :pub_information, localize: true
2018-10-04 02:47:23 +00:00
mount_uploader :cover, ImageUploader
2023-06-23 10:25:35 +00:00
field :cover_description, type: String
field :is_external_link, :type => Boolean, :default => false
field :external_link
field :is_online_flipping_reader, :type => Boolean, :default => false
has_many :full_files, :dependent => :destroy, :class_name => "PublicationFile"
has_many :publication_links, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :full_files, :allow_destroy => true
accepts_nested_attributes_for :publication_links, :allow_destroy => true
2018-10-04 02:47:23 +00:00
has_many :chapters, dependent: :destroy
2023-06-23 10:25:35 +00:00
def full_file
full_files[0]
end
2018-10-04 02:47:23 +00:00
end