2014-05-06 09:20:15 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
class PageContext
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
2014-05-15 11:29:59 +00:00
|
|
|
include OrbitModel::Impression
|
2024-02-24 02:22:17 +00:00
|
|
|
begin
|
|
|
|
include AutoConvertUnitHelper
|
|
|
|
rescue => e
|
|
|
|
puts "kernel is old!"
|
|
|
|
end
|
2014-05-06 09:20:15 +00:00
|
|
|
|
|
|
|
field :update_user_id
|
|
|
|
field :version, :type => Integer , :default => 0
|
|
|
|
field :view_count, :type => Integer, :default => 0
|
|
|
|
field :content, localize: true
|
|
|
|
field :archived, :type => Boolean, :default => false
|
|
|
|
# field :current, :type => Boolean, :default => false
|
|
|
|
|
|
|
|
belongs_to :page
|
2020-11-14 03:30:45 +00:00
|
|
|
before_create do |record|
|
|
|
|
last_version = record.page.page_contexts.order(:version=>-1).first.version rescue 0
|
|
|
|
record.version = last_version + 1
|
|
|
|
end
|
2014-05-06 09:20:15 +00:00
|
|
|
def pp_object
|
|
|
|
page.title
|
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
self.page.title
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|