Sha256: 467fab4a851ac20cc84550cc8d93112e6b7e83b719104b8443b13d9c847baed2

Contents?: true

Size: 1.69 KB

Versions: 58

Compression:

Stored size: 1.69 KB

Contents

class Venue
  include ::Mongoid::Document
  include ::Mongoid::Timestamps
  include Ish::Utils

  field :address

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

  field :slug
  validates :slug, :uniqueness => true, :allow_nil => false
  before_validation :set_slug

  field :subhead
  field :descr

  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 :tags

  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
  has_many :newsitems
  has_many :features

  PER_PAGE = 6

  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 :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

58 entries across 56 versions & 1 rubygems

Version Path
ish_models-0.0.33.194 lib/trash/venue.rb
ish_models-0.0.33.193 lib/trash/venue.rb
ish_models-0.0.33.192 lib/trash/venue.rb
ish_models-0.0.33.191 lib/trash/venue.rb
ish_models-0.0.33.190 lib/trash/venue.rb
ish_models-0.0.33.189 lib/trash/venue.rb
ish_models-0.0.33.188 lib/trash/venue.rb
ish_models-0.0.33.187 lib/trash/venue.rb
ish_models-0.0.33.186 lib/trash/venue.rb
ish_models-0.0.33.185 lib/trash/venue.rb
ish_models-0.0.33.184 lib/trash/venue.rb
ish_models-0.0.33.183 lib/trash/venue.rb
ish_models-0.0.33.182 lib/trash/venue.rb
ish_models-0.0.33.181 lib/trash/venue.rb
ish_models-0.0.33.180 lib/trash/venue.rb
ish_models-0.0.33.179 lib/trash/venue.rb
ish_models-0.0.33.178 lib/trash/venue.rb
ish_models-0.0.33.177 lib/venue.rb
ish_models-0.0.33.177 lib/trash/venue.rb
ish_models-0.0.33.176 lib/trash/venue.rb