33 lines
728 B
Ruby
33 lines
728 B
Ruby
class Page < Item
|
|
|
|
field :content
|
|
field :app_frontend_url
|
|
field :theme_id, :type => BSON::ObjectId, :default => nil
|
|
|
|
belongs_to :design
|
|
has_many :page_parts
|
|
belongs_to :module_app
|
|
|
|
embeds_many :custom_images, :class_name => 'Image', as: :design_image
|
|
|
|
def create_parts
|
|
page_design = self.design
|
|
page_design.layout.layout_parts.each do |p|
|
|
self.page_parts.create( :name => p.name, :i18n_variable_id => I18nVariable.create.id, :kind => 'text' ) if p.editable?
|
|
end
|
|
end
|
|
|
|
# Destroy the page_parts
|
|
def destroy_page_parts
|
|
self.page_parts.each do |part|
|
|
part.destroy_i18n_variable
|
|
part.destroy
|
|
end
|
|
end
|
|
|
|
def is_home?
|
|
self.parent ? false : true
|
|
end
|
|
|
|
end
|