OSDN Git Service

fix anything
[pettanr/pettanr.git] / app / models / comic.rb
index fbb04e2..5b7f9dc 100644 (file)
@@ -1,5 +1,6 @@
 #コミック
-class Comic < Pettanr::Content
+class Comic < Peta::Content
+  load_manifest
   has_many :stories, :order => 't'
   belongs_to :author
   
@@ -7,21 +8,28 @@ class Comic < Pettanr::Content
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   
-  @@valid_encode_columns += ['title', 'description']
-  @@visible_count_options = {:conditions => 'visible > 0'}
+  def self.visible_count_options
+    {:conditions => 'visible > 0'}
+  end
   
   def supply_default
     self.visible = 0 if self.visible.blank?
   end
   
-  def overwrite au
-    return false unless au
-    self.author_id = au.id
+  def overwrite operators
+    return false unless operators.author
+    self.author_id = operators.author.id
   end
   
   def visible? operators
-    super
-    self.visible > 0
+    case super
+    when nil # super return
+      return true
+    when false
+      return false
+    else
+      self.visible > 0
+    end
   end
   
   def comic_stories_count
@@ -31,7 +39,7 @@ class Comic < Pettanr::Content
   def symbol_filename
   end
   
-  def self.list_where
+  def self.public_list_where
     'comics.visible > 0'
   end
   
@@ -39,30 +47,6 @@ class Comic < Pettanr::Content
     'comics.updated_at desc'
   end
   
-  def self.mylist_where me
-    ['comics.author_id = ?', me.id]
-  end
-  
-  def self.mylist_order
-    'comics.updated_at desc'
-  end
-  
-  def self.himlist_where anybody
-    ['comics.author_id = ? and comics.visible > 0', anybody.id]
-  end
-  
-  def self.himlist_order
-    'comics.updated_at desc'
-  end
-  
-  def self.list_by_author_where author_id
-    ['comics.author_id = ?', author_id]
-  end
-  
-  def self.list_by_author author_id, roles, page = 1, page_size = self.default_page_size
-    self.where(self.list_by_author_where(author_id)).includes(self.list_opt).order('comics.updated_at desc').offset((page -1) * page_size).limit(page_size)
-  end
-  
   def self.list_opt
     {:stories => {}, :author => {} }
   end
@@ -79,6 +63,11 @@ class Comic < Pettanr::Content
     {:include => {:stories => {}, :author => {}} }
   end
   
+  def tag_attributes column = nil, opt = {}
+    {
+    }
+  end
+  
   def destroy_with_story
     res = false
     Comic.transaction do