OSDN Git Service

fix anything
[pettanr/pettanr.git] / app / models / sheet.rb
index 269dd21..a07bbea 100644 (file)
@@ -1,4 +1,5 @@
-class Sheet < Peta::Content
+class Sheet < Peta::Root
+  load_manifest
   has_many :sheet_panels
   has_many :story_sheets
   belongs_to :author
@@ -9,10 +10,6 @@ class Sheet < Peta::Content
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   accepts_nested_attributes_for :sheet_panels, :allow_destroy => true
   
-  def self.valid_encode_columns
-    super + ['caption']
-  end
-  
   def self.each_element_class_names
     {'SheetPanel' => 'sheet_panels'}.each do |k, n|
       yield k
@@ -44,9 +41,14 @@ class Sheet < Peta::Content
   end
   
   def visible? operators
-    return false unless super
-    return true if self.new_record?
-    self.visible > 0
+    case super
+    when nil # super return
+      return true
+    when false
+      return false
+    else
+      self.visible > 0
+    end
   end
   
   def usable? operators
@@ -56,19 +58,7 @@ class Sheet < Peta::Content
   def symbol_filename
   end
   
-  def tag_id
-    'sheet' + self.tag_sheet_id
-  end
-  
-  def tag_sheet_id
-    self.new_record? ? '0' : self.id.to_s
-  end
-  
-  def field_tag_id f
-    self.tag_id + f.to_s
-  end
-  
-  def self.list_where
+  def self.public_list_where
     'sheets.visible > 0'
   end
   
@@ -176,16 +166,6 @@ class Sheet < Peta::Content
     Sheet.validate_elements_serial validate_serial_list
   end
   
-  def boost
-    @new_element_index = 0
-    self.panel_elements.each do |elm|
-      if elm.new_record?
-        elm.new_index = @new_element_index
-        @new_element_index += 1
-      end
-    end
-  end 
-  
   def store attr, operators
     if attr == false
       self.errors.add :base, I18n.t('errors.invalid_json')