31 lines
604 B
Ruby
31 lines
604 B
Ruby
class Page < Item
|
|
|
|
field :content
|
|
|
|
validates_presence_of :design_id
|
|
|
|
belongs_to :design
|
|
belongs_to :theme
|
|
has_many :page_parts
|
|
|
|
def create_parts
|
|
page_design = self.get_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 get_design
|
|
Design.find(design_id)
|
|
end
|
|
|
|
end
|