OSDN Git Service

fic picture publishing
[pettanr/pettanr.git] / app / models / writing_format.rb
index e7d04a2..5e54402 100644 (file)
@@ -1,4 +1,5 @@
-class WritingFormat < Pettanr::Item
+class WritingFormat < Peta::SystemResource
+  load_manifest
   has_many :speeches
   belongs_to :system_picture
   
@@ -9,22 +10,6 @@ class WritingFormat < Pettanr::Item
   validates :system_picture_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :settings, :presence => true
   
-  def self.singular
-    'WritingFormat'
-  end
-  
-  def self.plural
-    'WritingFormats'
-  end
-  
-  def self.owner_type
-    :author
-  end
-  
-  def self.valid_encode_columns
-    super.merge ['name', 'classname', 'caption', 'settings']
-  end
-  
   def supply_default
   end
   
@@ -32,19 +17,21 @@ class WritingFormat < Pettanr::Item
     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
@@ -57,14 +44,6 @@ class WritingFormat < Pettanr::Item
     {}
   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
@@ -86,12 +65,16 @@ class WritingFormat < Pettanr::Item
     @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