Orbit/app/models/desktop/desktop_widget.rb

34 lines
933 B
Ruby
Raw Permalink Normal View History

2012-11-01 12:42:40 +00:00
class DesktopWidget
include Mongoid::Document
include Mongoid::Timestamps
include ParserLayoutWidget
field :name
field :author
field :shape
field :fullsize, :type => Boolean
2012-11-01 12:42:40 +00:00
field :version, :type => String
2012-11-05 15:04:54 +00:00
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
2012-11-01 12:42:40 +00:00
has_one :widget_layout, :autosave => true, :dependent => :destroy
2012-11-05 15:04:54 +00:00
has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
has_and_belongs_to_many :desktops, :autosave => true
has_many :tiles, :autosave => true
2012-11-01 12:42:40 +00:00
accepts_nested_attributes_for :images, :allow_destroy => true
2012-11-05 15:04:54 +00:00
accepts_nested_attributes_for :javascripts, :allow_destroy => true
2012-11-01 12:42:40 +00:00
after_save :parse_css_for_images
# belongs_to :desktop
protected
def parse_css_for_images
2012-11-05 15:04:54 +00:00
self.css_default.parse_urls
2012-11-01 12:42:40 +00:00
parse_widget_for_images(self)
end
end