This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/models/page.rb

31 lines
819 B
Ruby
Raw Normal View History

class Page < Item
2010-01-04 07:52:30 +00:00
field :content
2011-12-23 10:34:21 +00:00
field :app_frontend_url
field :theme_id, :type => BSON::ObjectId, :default => nil
2010-01-28 09:42:55 +00:00
belongs_to :design
2011-12-23 10:34:21 +00:00
belongs_to :module_app
has_many :page_parts, :autosave => true, :dependent => :destroy
2012-02-21 11:22:42 +00:00
has_many :page_contexts, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :page_parts, :allow_destroy => true
2010-01-28 09:42:55 +00:00
before_save :create_parts
# embeds_many :custom_images, :class_name => 'Image', as: :design_image
2011-10-18 03:21:24 +00:00
def is_home?
self.parent ? false : true
end
protected
2011-06-01 02:24:14 +00:00
def create_parts
page_design = self.design
page_design.layout.layout_parts.each do |layout_part|
self.page_parts.new(:name => layout_part.name) unless self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
2011-06-01 04:00:41 +00:00
end
end
2011-03-01 07:58:42 +00:00
end