Merge with sub_roles

This commit is contained in:
chris2tof committed 2011-12-23 18:34:21 +08:00
1 parent fc591ee308
commit 62aaf79491
308 files changed
+2844 -17841

No files matched your search

+34 -2
View File
@@ -24,6 +24,35 @@ class Design
after_save :procs_embedded_objects
# after_destroy :del_embedded_objects
# validate do
# errors.add('atttribute1', 'error for 1') if files_with_duplicate?
# errors.add('atttribute2', 'error for 1') if files_with_noname?
# end
def files_with_duplicate?
[self.javascripts, self.images,self.themes].each do |objects_hash|
ary = objects_hash.collect{ |k| k.file_filename}
ary.compact!
# debugger
return true if(ary.count!=ary.uniq.count)
end
false
end
def files_with_noname?
[self.javascripts, self.images,self.themes].each do |objects_hash|
objects_hash.each{ |k|
return true if(k.file_filename.nil? && !k.to_save?)
}
end
false
end
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
@@ -36,7 +65,7 @@ class Design
self.files = (attrs << 'images')
end
# Update or create the attribute_model records
# Update or create the attribute records
def files=(attrs)
case attrs.last
when 'layout'
@@ -45,6 +74,7 @@ class Design
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
@@ -86,12 +116,14 @@ class Design
end
end
end
self.valid?
end
def process_object(object)
if object.to_save
if object.file_filename.nil?
new_object = self.send(object._type.downcase.pluralize).build(object)
new_object = self.send(object._type.downcase.pluralize).build(object.attributes)
new_object.file = object.file
object.destroy
new_object.to_save = false
new_object.save
+1 -1
View File
@@ -1,5 +1,5 @@
class Layout < DesignFile
include Parser
include ParserLayout
attr_reader :content