Edit uploaded package

This commit is contained in:
chris committed 2012-10-26 11:19:57 +08:00
1 parent 0a1a9d2c2e
commit d7fd61ce55
28 files changed
+256 -251

No files matched your search

+16 -18
View File
@@ -3,25 +3,27 @@ class Design
include Mongoid::Timestamps
include ParserLayout
field :title, :type => String
field :author, :type => String
field :intro, :type => String
field :title, :type => String
field :version, :type => String
has_one :css_default, :autosave => true, :dependent => :destroy
has_one :layout, :autosave => true, :dependent => :destroy
has_one :css_reset, :autosave => true, :dependent => :destroy
has_many :images, :autosave => true, :dependent => :destroy
has_many :javascripts, :autosave => true, :dependent => :destroy
has_many :pages
embeds_one :layout, :cascade_callbacks => true
embeds_one :default_css, :class_name => "Stylesheet", :cascade_callbacks => true
embeds_one :reset_css, :class_name => "Stylesheet", :cascade_callbacks => true
embeds_many :themes, :cascade_callbacks => true
embeds_many :javascripts, :cascade_callbacks => true
embeds_many :images, :as => :design_image, :cascade_callbacks => true
# embeds_many :custom_images, :class_name => 'Image', :cascade_callbacks => true
validates_presence_of :title
validates_presence_of :author
has_many :themes, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :images, :allow_destroy => true
accepts_nested_attributes_for :javascripts, :allow_destroy => true
accepts_nested_attributes_for :themes, :allow_destroy => true
validates_presence_of :author, :title
after_save :parse_css_for_images
def new_files=(*attrs)
attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs
@@ -66,13 +68,9 @@ class Design
protected
def parse_css_for_images
if (self.default_css && self.default_css.changed)
self.default_css.parse_urls
end
self.css_default.parse_urls
self.themes.each do |theme|
if theme.changed?
theme.parse_urls
end
theme.parse_urls
end
parse_body_for_images(self)
end