adding files not commited from previous commit

This commit is contained in:
Matthew Fu committed 2011-07-12 16:02:41 +08:00
1 parent f387139ae1
commit f73f09ffcf
726 files changed
+129696

No files matched your search

Binary file not shown.
+71
View File
@@ -0,0 +1,71 @@
class Design
include Mongoid::Document
include Mongoid::Timestamps
field :title
field :author
field :intro
field :version
validates_presence_of :title
validates_presence_of :author
mount_uploader :layout, DesignFileUploader
embeds_many :stylesheets
embeds_many :javascripts
embeds_many :images
after_update :destroy_attrs
def javascripts=(*attrs)
self.attribute_models=(attrs<<'javascripts')
end
def stylesheets=(*attrs)
self.attribute_models=(attrs<<'stylesheets')
end
def images=(*attrs)
self.attribute_models=(attrs<<'images')
end
# Update or create the attribute_model records
def attribute_models=(attrs)
#attribute_models = eval(attributes[:type])
# if attributes.original_filename.blank?
attribute_models=eval(attrs.last)
a=attribute_models.build()
a.file=attrs[0]
# else
# attribute_model = attribute_models.detect {|a| a.id.to_s == attributes[:id].to_s }
# attribute_model.update_attributes(attributes)
#end
end
def is_built_in?
self.built_in
end
def is_disabled?
self.disabled
end
def get_enabled_attribute_models
self.attribute_models.excludes('disabled' => true)
end
protected
# Destroy the i18n_variable for each attribute_models if marked to destroy
def destroy_attrs
=begin
attribute_models.each do |a|
if a.should_destroy?
a.destroy_i18n_variable
end
end
=end
end
end
+6
View File
@@ -0,0 +1,6 @@
class DesignFile
include Mongoid::Document
mount_uploader :file, AssetUploader
end
+3
View File
@@ -0,0 +1,3 @@
class Image<DesignFile
end
+3
View File
@@ -0,0 +1,3 @@
class Javascript<DesignFile
end
+5
View File
@@ -0,0 +1,5 @@
class Stylesheet < DesignFile
mount_uploader :file, AssetUploader
embedded_in :design
end