Sha256: 3dc72e6fb3eb8606448cba3a9f9d6bfe9b258dd12b8e1ceeac1b25ba0d2e1e4f

Contents?: true

Size: 1.69 KB

Versions: 43

Compression:

Stored size: 1.69 KB

Contents

class Venue
  include ::Mongoid::Document
  include ::Mongoid::Timestamps

  field :name, :type => String
  validates :name, :uniqueness => true, :allow_nil => false

  field :name_seo, :type => String
  validates :name_seo, :uniqueness => true, :allow_nil => false
  
  field :descr, :type => String
  
  field :is_trash, :type => Boolean, :default => false
  scope :fresh, ->{ where({ :is_trash => false }) }
  scope :trash, ->{ where({ :is_trash => true }) }

  field :is_public, :type => Boolean, :default => true
  scope :public, ->{ where({ :is_public => true }) }
  scope :not_public, ->{ where({ :is_public => false }) }

  field :is_feature, :type => Boolean, :default => false

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

  field :lang, :type => String, :default => 'en'

  belongs_to :city
  # belongs_to :owner, :class_name => 'User', :inverse_of => :owned_venue
  validates :city, :allow_nil => false, :presence => true

  has_and_belongs_to_many :users

  has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_venue

  has_many :reports
  has_many :galleries
  has_many :photos

  embeds_many :newsitems
  embeds_many :features

  def self.list conditions = { :is_trash => false }
    out = self.where( conditions).order_by( :name => :asc )
    [['', nil]] + out.map { |item| [ item.name, item.id ] }
  end

  set_callback :create, :before do |doc|
    doc.name_seo = doc.name.gsub(' ', '-')
  end

  set_callback :save, :before do |doc|
    if doc.city
      city.touch
    end
  end

  def self.types
    return []
#    if 'en' == @locale
#      [ 'Hotels', 'Restaurants', 'Bars' ]
#    else
#      [ 'Hotels', 'Restaurants', 'Bars' ]
#    end
  end

  def self.n_features
    6
  end

end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
ish_models-0.0.33.61 lib/venue.rb
ish_models-0.0.33.60 lib/venue.rb
ish_models-0.0.33.59 lib/venue.rb
ish_models-0.0.33.58 lib/venue.rb
ish_models-0.0.33.57 lib/venue.rb
ish_models-0.0.33.56 lib/venue.rb
ish_models-0.0.33.55 lib/venue.rb
ish_models-0.0.33.54 lib/venue.rb
ish_models-0.0.33.53 lib/venue.rb
ish_models-0.0.33.52 lib/venue.rb
ish_models-0.0.33.50 lib/venue.rb
ish_models-0.0.33.49 lib/venue.rb
ish_models-0.0.33.48 lib/venue.rb
ish_models-0.0.33.47 lib/venue.rb
ish_models-0.0.33.46 lib/venue.rb
ish_models-0.0.33.45 lib/venue.rb
ish_models-0.0.33.44 lib/venue.rb
ish_models-0.0.33.43 lib/venue.rb
ish_models-0.0.33.42 lib/venue.rb
ish_models-0.0.33.41 lib/venue.rb