Sha256: 72beefbb50187b2a594b741c5d991079002332b6dc03279b501737f72da4de3c

Contents?: true

Size: 1.45 KB

Versions: 130

Compression:

Stored size: 1.45 KB

Contents

class PublicItem

=begin
  ## let's try to make it work with newsitems, without publicitems yet.

  include Mongoid::Document
  include Mongoid::Timestamps

  belongs_to :site
  belongs_to :city
  belongs_to :tag
  
  field :username

  # acts as a report
  # acts as a gallery
  # acts as a video  
  has_many :photos

  belongs_to :photo
  belongs_to :report
  belongs_to :gallery
  belongs_to :video

  field :name, :type => String
  field :descr, :type => String
  field :image_path, :type => String
  field :link_path, :type => String
  field :username, :type => String # @TODO do I use this???
  field :partial_name, :type => String, :default => nil  # @deprecated, but let's not remove it.

  field :weight, :type => Integer, :default => 10
  field :n_upvotes, :type => Integer, :default => 0
  field :n_downvotes, :type => Integer, :default => 0
  field :upvoting_users, :type => Array, :default => []
  field :downvoting_users, :type => Array, :default => []
  field :is_feature, :type => Boolean, :default => false

  default_scope ->{ order_by({ :created_at => :desc }) }

  def self.from_params item
    n = Newsitem.new
    n.descr = item[:descr]
    n.username = item[:username]

    unless item[:report_id].blank?
      n.report = Report.find item[:report_id]
    end
    
    unless item[:gallery_id].blank?
      n.gallery = Gallery.find item[:gallery_id]
    end

    n.partial_name = item.partial_name unless item.partial_name.blank?

    return n
  end
=end

end

Version data entries

130 entries across 130 versions & 1 rubygems

Version Path
ish_models-0.0.33.140 lib/public_item.rb
ish_models-0.0.33.139 lib/public_item.rb
ish_models-0.0.33.138 lib/public_item.rb
ish_models-0.0.33.137 lib/public_item.rb
ish_models-0.0.33.136 lib/public_item.rb
ish_models-0.0.33.135 lib/public_item.rb
ish_models-0.0.33.134 lib/public_item.rb
ish_models-0.0.33.133 lib/public_item.rb
ish_models-0.0.33.132 lib/public_item.rb
ish_models-0.0.33.131 lib/public_item.rb
ish_models-0.0.33.130 lib/public_item.rb
ish_models-0.0.33.129 lib/public_item.rb
ish_models-0.0.33.128 lib/public_item.rb
ish_models-0.0.33.127 lib/public_item.rb
ish_models-0.0.33.124 lib/public_item.rb
ish_models-0.0.33.123 lib/public_item.rb
ish_models-0.0.33.122 lib/public_item.rb
ish_models-0.0.33.121 lib/public_item.rb
ish_models-0.0.33.120 lib/public_item.rb
ish_models-0.0.33.119 lib/public_item.rb