Sha256: 75d736826b8f0789e92e230c0da821483b6c3ab4b40a5c18fa50ee8919911d4d

Contents?: true

Size: 1.82 KB

Versions: 19

Compression:

Stored size: 1.82 KB

Contents

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

  field :name, :type => String
  validates :name, uniqueness: true, presence: true, allow_nil: false # @TODO: tags should only be unique globally, and per-user.

  field :slug
  validates :slug, uniqueness: true, presence: true, allow_nil: false

  field :descr, :type => String, :default => ''

  field :is_public,  :type => Boolean, :default => true
  field :is_trash,   :type => Boolean, :default => false
  field :is_feature, :type => Boolean, :default => false

  field :weight, :type => Integer, :default => 10

  has_many :children_tags, :class_name => 'Tag', :inverse_of => :parent_tag
  belongs_to :parent_tag, :class_name => 'Tag', :inverse_of => :children_tags, :optional => true

  has_many :features
  has_many :newsitems

  belongs_to :site, :optional => true
  belongs_to :city, :optional => true

  has_and_belongs_to_many :venues
  has_and_belongs_to_many :cities
  has_and_belongs_to_many :galleries
  has_and_belongs_to_many :reports
  has_and_belongs_to_many :videos
  has_and_belongs_to_many :maps, class_name: 'Gameui::Map'

  before_validation :set_slug

  def self.clear
    if Rails.env.test?
      Tag.each { |r| r.remove }
    end
  end

  def self.no_parent
    Tag.where( :parent_tag_id => nil )
  end

  # the first blank used to be disabled, not anymore _vp_ 20180418
  def self.list
    out = Tag.unscoped.order_by( :name => :asc )
    return( [['', nil]] + out.map { |item| [ item.name, item.id ] } )
  end

  # @deprecated, there will be no reports or galleries in tags. There will be only features and newsitems
  def self.n_items
    10
  end
  def self.n_reports
    4
  end
  def self.n_galleries
    4
  end
  def self.n_videos
    4
  end

  def self.n_features
    4
  end
  field :n_features, type: Integer, default: 4

end

Version data entries

19 entries across 19 versions & 1 rubygems

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