X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fmodels%2Fground_picture.rb;h=bd1d16d712ef28b496391870c9be499df3e5efff;hb=bccda72efb698fa4813711f28d0b263f249bf6d6;hp=ab5a2445839ddab56d6fbb6cdffb86464048618e;hpb=ecf9b1a88198581aa2bbede0486ca93116d59d73;p=pettanr%2Fpettanr.git diff --git a/app/models/ground_picture.rb b/app/models/ground_picture.rb index ab5a2445..bd1d16d7 100644 --- a/app/models/ground_picture.rb +++ b/app/models/ground_picture.rb @@ -11,6 +11,26 @@ class GroundPicture < Peta::Element validates :z, :presence => true, :numericality => {:greater_than => 0} validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0} + scope :with_panel, -> do + includes(:panel) + end + + scope :find_index, -> do + with_panel.where(Panel.arel_table[:publish].gt 0).references(:panel) + end + + scope :find_private, -> (operators) do + with_panel.where(Panel.arel_table[:author_id].eq operators.author.id).references(:panel) + end + + scope :find_by_panel, -> (panel_id) do + find_index.where(panel_id: panel_id).references(:panel) + end + + scope :find_by_author, -> (author_id) do + find_index.where(Panel.arel_table[:author_id].eq author_id).references(:panel) + end + @@repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] def self.pickup_item_name