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_part.rb

45 lines
927 B
Ruby
Raw Normal View History

2011-05-18 02:00:00 +00:00
class PagePart
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :content, localize: true
field :kind
field :public_r_tag
2012-04-23 18:30:40 +00:00
field :public_r_tag_object_id, :default => nil
2012-05-08 20:15:45 +00:00
field :public_r_tag_option, :default => nil
field :page_title, localize: true
field :widget_path
2012-08-09 07:25:30 +00:00
2012-07-16 08:13:38 +00:00
field :widget_style
2012-07-26 08:39:29 +00:00
field :widget_field , :type => Array
2012-12-28 07:30:46 +00:00
field :widget_options ,:type=>Hash
2012-07-16 08:13:38 +00:00
field :widget_data_count
2011-05-18 02:00:00 +00:00
belongs_to :page
belongs_to :module_app
2011-05-18 02:00:00 +00:00
before_save :delete_empty_widget_field
after_save :update_parent
2012-12-28 07:30:46 +00:00
def widget_options_uri
self.widget_options.map{|t| "#{t[0]}: #{t[1]}"}.join(',') rescue ''
end
protected
2012-08-09 07:25:30 +00:00
def delete_empty_widget_field
if self.widget_field
self.widget_field.reject! { |wf| (wf[0].blank? || wf[1].blank?) }
end
2012-08-09 07:25:30 +00:00
# self.widget_field.delete("") if self.widget_field
end
def update_parent
self.page.save
end
2012-12-28 07:30:46 +00:00
2011-05-18 02:00:00 +00:00
end