OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / models / scroll_panel.rb
1 class ScrollPanel < Peta::Leaf
2   load_manifest
3   belongs_to :author
4   belongs_to :panel
5   belongs_to :scroll
6   
7   validates :scroll_id, :presence => true, :numericality => true, :existence => {:both => false}
8   validates :panel_id, :presence => true, :numericality => true, :existence => {:both => false}
9   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
10   
11   def supply_default
12     self.scroll_id = nil
13     self.panel_id = nil
14     self.t = nil
15   end
16   
17   def overwrite operators
18   end
19   
20   def self.public_list_where list
21     'scrolls.visible > 0'
22   end
23   
24   def self.by_author_list_includes
25     {
26       :scroll => {
27         :author => {}
28       }
29     }
30   end
31   
32   def self.show_opt
33     {:include => {
34       :scroll => {
35         :author => {}
36       }, 
37     }}
38   end
39   
40   def self.licensed_pictures scroll_panels
41     Panel.licensed_pictures scroll_panels.select {|sp| sp.panel }.map {|sp| sp.panel }
42   end
43   
44   def allow? operators
45     return nil if self.scroll_id == nil or self.panel_id == nil
46     self.scroll.own?(operators) and self.panel.usable?(operators)
47   end
48   
49 end