-class WritingFormat < ActiveRecord::Base
+class WritingFormat < Peta::Item
+ load_manifest
has_many :speeches
belongs_to :system_picture
validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
validates :settings, :presence => true
- before_validation :valid_encode
-
- def valid_encode
- ['name', 'classname', 'caption', 'settings'].each do |a|
- next if attributes[a] == nil
- raise Pettanr::BadRequest unless attributes[a].valid_encoding?
- end
- end
-
def supply_default
end
self.t = WritingFormat.count.to_i if self.new_record?
end
- def visible? author
- true
+ def self.list_where
+ nil
end
- def self.list
- opt = {}
- opt.merge!(self.list_opt)
- opt.merge!({:order => 'writing_formats.t asc'})
- WritingFormat.find(:all, opt)
+ def self.list_order
+ 'writing_formats.t asc'
end
+#engine vw
+def self.list
+ self.enable_list
+end
def self.enable_list
- WritingFormat.list.delete_if {|wf|
+ WritingFormat.find(:all).delete_if {|wf|
wf.enable? == false
}
end
{}
end
- def self.show rid, au
- opt = {}
- opt.merge!(self.show_opt)
- res = WritingFormat.find(rid, opt)
- raise ActiveRecord::Forbidden unless res.visible?(au)
- res
- end
-
def self.show_opt
{}
end
@parsed_settings ||= JSON.parse(self.settings)
end
+ def my_engine_resource
+ Manifest.manifest.system_resources.engine_resources['writing_formats']
+ end
+
def engine_name
- Pettanr::Application.manifest.system_resources.writing_formats[self.classname]
+ self.my_engine_resource.resource_items[self.classname]
end
def enable?
- Pettanr::Application.manifest.system_resources.writing_formats.include? self.classname
+ self.my_engine_resource.resource_items.include? self.classname
end
def engine_module_name