Sha256: a08c50fbe432985b38e7e0d36d5db884ae628abd3d7757e6544d0e0451ca6fb3

Contents?: true

Size: 1.63 KB

Versions: 19

Compression:

Stored size: 1.63 KB

Contents

class Gallery
  include ::Mongoid::Document
  include ::Mongoid::Timestamps
  include Ish::PremiumItem
  include Ish::Utils

  PER_PAGE = 6

  field :name
  validates :name, :uniqueness => true
  field :subhead
  field :descr,   :as => :description

  field :is_public,  type: Boolean, default: false
  has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_galleries

  field :is_trash,   type: Boolean, default: false
  field :is_done,    type: Boolean, default: false

  default_scope ->{ where({ :is_public => true, :is_trash => false }).order_by({ :created_at => :desc }) }

  field :x,       :type => Float
  field :y,       :type => Float
  field :z,       :type => Float

  field :lang,    :default => 'en'
  field :username

  field :slug
  index({ :slug => -1 }, { :unique => true })
  validates :slug, presence: true, uniqueness: true
  before_validation :set_slug, :on => :create

  def self.list conditions = { :is_trash => false }
    out = self.unscoped.where( conditions ).order_by( :created_at => :desc )
    [['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
  end

  belongs_to :user_profile, :optional => true, :class_name => 'Ish::UserProfile', :inverse_of => :galleries

  has_many :newsitems # Seems correct. _vp_ 2022-03-21

  has_many :photos, order: { ordering: :asc }

  ACTIONS = [ 'show_mini', 'show_long', 'show' ]
  # @deprecated, use Gallery::ACTIONS
  def self.actions
    ACTIONS
  end


  RENDER_TITLES = 'index_titles' # view name
  RENDER_THUMBS = 'index_thumbs' # view name

  def export_fields
    %w| name subhead descr |
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ish_models-0.0.33.242 lib/gallery.rb
ish_models-0.0.33.241 lib/gallery.rb
ish_models-0.0.33.240 lib/gallery.rb
ish_models-0.0.33.239 lib/gallery.rb
ish_models-0.0.33.238 lib/gallery.rb
ish_models-0.0.33.237 lib/gallery.rb
ish_models-0.0.33.236 lib/gallery.rb
ish_models-0.0.33.235 lib/gallery.rb
ish_models-0.0.33.234 lib/gallery.rb
ish_models-0.0.33.233 lib/gallery.rb
ish_models-0.0.33.232 lib/gallery.rb
ish_models-0.0.33.231 lib/gallery.rb
ish_models-0.0.33.230 lib/gallery.rb
ish_models-0.0.33.229 lib/gallery.rb
ish_models-0.0.33.228 lib/gallery.rb
ish_models-0.0.33.227 lib/gallery.rb
ish_models-0.0.33.226 lib/gallery.rb
ish_models-0.0.33.225 lib/gallery.rb
ish_models-0.0.33.224 lib/gallery.rb