2010-01-14 10:30:53 +00:00
|
|
|
class Page < Item
|
2010-01-04 07:52:30 +00:00
|
|
|
|
2011-04-13 10:19:51 +00:00
|
|
|
field :content
|
2011-08-25 07:44:52 +00:00
|
|
|
field :theme_id, :type => BSON::ObjectId
|
2010-01-28 09:42:55 +00:00
|
|
|
|
2011-08-22 05:45:21 +00:00
|
|
|
belongs_to :design
|
2011-05-18 02:00:00 +00:00
|
|
|
has_many :page_parts
|
2010-01-28 09:42:55 +00:00
|
|
|
|
2011-06-01 02:24:14 +00:00
|
|
|
def create_parts
|
2011-08-25 00:13:38 +00:00
|
|
|
page_design = self.design
|
2011-08-08 01:30:44 +00:00
|
|
|
page_design.layout.layout_parts.each do |p|
|
2011-08-25 00:13:38 +00:00
|
|
|
self.page_parts.create( :name => p.name, :i18n_variable_id => I18nVariable.create.id, :kind => 'text' ) if p.editable?
|
2011-06-01 02:24:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-01 04:00:41 +00:00
|
|
|
# Destroy the page_parts
|
|
|
|
def destroy_page_parts
|
|
|
|
self.page_parts.each do |part|
|
|
|
|
part.destroy_i18n_variable
|
|
|
|
part.destroy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-01 07:58:42 +00:00
|
|
|
end
|