- template list/show is loaded from central server

- buy a template downloads and creates it in DB
- changes in designs index
This commit is contained in:
chris committed 2012-12-06 23:20:27 +08:00
1 parent eb53343bdb
commit 6f1748d2b3
12 files changed
+195 -96

No files matched your search

+5 -41
View File
@@ -8,62 +8,26 @@ class Design
field :title, :type => String
field :version, :type => String
mount_uploader :zip_file, AssetUploader
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
has_one :layout, :autosave => true, :dependent => :destroy
has_one :css_reset, :autosave => true, :dependent => :destroy
has_one :thumb, :autosave => true, :dependent => :destroy
has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
has_many :pages
has_many :screenshots, :autosave => true, :dependent => :destroy
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 :screenshots, :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
self.files=([items_ary, key])
end
end
# def javascripts=(*attrs)
# self.files = (attrs << 'javascripts')
# end
#
# def themes=(*attrs)
# self.files = (attrs << 'themes')
# end
#
# def images=(*attrs)
# self.files = (attrs << 'images')
# end
# Update or create the attribute records
def files=(attrs)
case attrs.last
when 'layout'
files = self.layout.build
else
files = eval(attrs.last)
end
attrs[0].each do |a|
if a[:id].blank? && !a[:file].blank?
files.build(:file => a[:file], :to_save => true)
else
files.each do |file|
if file.id.to_s == a[:id]
file.to_destroy = a[:to_destroy]
end
end
end
end
end
protected
+3
View File
@@ -0,0 +1,3 @@
class Screenshot < Image
belongs_to :design
end
+3
View File
@@ -0,0 +1,3 @@
class Thumb < Image
belongs_to :design
end