1 class ScrollPanel < Peta::Leaf
7 validates :scroll_id, :presence => true, :numericality => true, :existence => {:both => false}
8 validates :panel_id, :presence => true, :numericality => true, :existence => {:both => false}
9 validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
10 validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
18 def overwrite operators
19 return false unless operators.author
20 self.author_id = operators.author.id
23 def self.public_list_order
24 'scroll_panels.updated_at desc'
27 def self.public_list_where
39 :panel_pictures => {:picture => {:artist => {}, :license => {}}},
40 :speech_balloons =>{:balloon => {}, :speech => {}}
45 def self.list_json_opt
53 :panel_pictures => {:picture => {:artist => {}, :license => {}}},
54 :speech_balloons =>{:balloon => {}, :speech => {}}
67 :panel_pictures => {:picture => {:artist => {}, :license => {}}},
68 :speech_balloons =>{:balloon => {}, :speech => {}}
73 def self.licensed_pictures scroll_panels
75 scroll_panels.each do |scroll_panel|
76 r.merge!(scroll_panel.panel.licensed_pictures) if scroll_panel.panel
82 return nil if self.scroll_id == nil or self.panel_id == nil
83 self.scroll.own?(operators) and self.panel.usable?(operators)
86 def store operators, old_t = nil
88 self.class.transaction do
89 case self.allow? operators
93 raise ActiveRecord::Forbidden
97 raise ActiveRecord::Rollback unless res
98 res = self.class.validate_t(self.scroll_id)
100 self.errors.add :t, 'unserialized'
101 raise ActiveRecord::Rollback