1 class Sheet < Peta::Root
7 validates :caption, :presence => true, :length => {:maximum => 100}
8 validates :width, :presence => true, :numericality => true, :natural_number => true
9 validates :height, :presence => true, :numericality => true, :natural_number => true
10 validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
11 accepts_nested_attributes_for :sheet_panels, :allow_destroy => true
14 self.visible = 0 if self.visible.blank?
18 def overwrite operators
19 return false unless operators.author
20 self.author_id = operators.author.id
23 def visible? operators
25 when nil # super return
35 self.visible? operators
41 def self.public_list_where list
46 {:include => {:sheet_panels => {:panel => {}}, :author => {}}}
49 def self.show_json_opt
50 {:include => {:sheet_panels => {:include => {:panel => {}}}, :author => {}}}
67 self.scenario_elements.each do |elm|
68 r.merge!(elm.licensed_pictures)
75 self.elements_items.each do |elm|