Sha256: 53409660ff4035f4ef9af665e7a5a884e8d40bf194612170b45cb20d540dfe59

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

module Enjoy
  module Models
    module Mongoid
      module News
        extend ActiveSupport::Concern
        unless Enjoy.config.news_image_styles.nil?
          include Enjoy::MongoidPaperclip
        end

        include Enjoy::HtmlField

        included do
          field :name, type: String, localize: Enjoy.config.localize, default: ""

          field :time, type: Time
          index({enabled: 1, time: 1})
          unless Enjoy.config.news_image_styles.nil?
            enjoy_cms_mongoid_attached_file(:image,
                      styles: Enjoy.configuration.news_image_styles,
                      convert_options: Enjoy.configuration.news_image_convert_options,
                      content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
            )
          end

          enjoy_cms_html_field :excerpt, type: String, localize: Enjoy.configuration.localize, default: ""
          enjoy_cms_html_field :content, type: String, localize: Enjoy.configuration.localize, default: ""

          scope :after_now, -> { where(:time.lt => Time.now) }
          scope :by_date, -> { desc(:time) }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enjoy_cms-0.3.0.4 lib/enjoy/models/mongoid/news.rb
enjoy_cms-0.3.0.3 lib/enjoy/models/mongoid/news.rb
enjoy_cms-0.3.0.2 lib/enjoy/models/mongoid/news.rb