2013-12-25 10:39:05 +00:00
|
|
|
class Template
|
2014-01-10 08:48:23 +00:00
|
|
|
|
2013-12-25 10:39:05 +00:00
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
2013-12-26 09:49:49 +00:00
|
|
|
include Mongoid::Slug
|
2014-01-10 08:48:23 +00:00
|
|
|
include Mongoid::Elasticsearch
|
2013-12-25 10:39:05 +00:00
|
|
|
|
|
|
|
field :title, type: String
|
|
|
|
field :author, type: String
|
2013-12-26 09:49:49 +00:00
|
|
|
field :preview, type: String
|
|
|
|
field :template, type: String
|
2014-01-10 08:48:23 +00:00
|
|
|
field :category_id, type: String
|
2014-03-14 06:37:59 +00:00
|
|
|
field :price, type: Float
|
|
|
|
field :description, type: String
|
2014-01-10 08:48:23 +00:00
|
|
|
|
2013-12-26 09:49:49 +00:00
|
|
|
slug :title, history: true
|
2014-01-10 08:48:23 +00:00
|
|
|
belongs_to :category
|
2013-12-25 10:39:05 +00:00
|
|
|
|
2014-03-14 06:37:59 +00:00
|
|
|
IMAGE_SIZES = {
|
|
|
|
:thumb => [256, 180]
|
|
|
|
}
|
|
|
|
|
2013-12-25 10:39:05 +00:00
|
|
|
mount_uploader :preview, ImageUploader
|
|
|
|
mount_uploader :template, ProductUploader
|
2014-01-10 08:48:23 +00:00
|
|
|
|
|
|
|
elasticsearch!
|
2014-03-14 06:37:59 +00:00
|
|
|
|
|
|
|
SORT_TYPE = %w{Popular New Preferred}
|
|
|
|
|
|
|
|
def self.get_categories
|
|
|
|
categories = Category.where(type: "Extension")
|
|
|
|
end
|
2013-12-25 10:39:05 +00:00
|
|
|
end
|