X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fmodels%2Fground_picture.rb;h=bd1d16d712ef28b496391870c9be499df3e5efff;hb=0ead3a286b925e86845cf8211982a7985e522813;hp=9ac6bc5df97c208eca29ab1c669dbaff2ac7f765;hpb=21b5715256f5db32b8136344a8f80148f915f41e;p=pettanr%2Fpettanr.git diff --git a/app/models/ground_picture.rb b/app/models/ground_picture.rb index 9ac6bc5d..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 @@ -61,7 +81,7 @@ class GroundPicture < Peta::Element 'position' => 'absolute', 'top' => '0px', 'left' => '0px', 'z-index' => self.z, 'background-image' => "url(#{self.picture.url})", 'background-repeat' => self.repeat_text, - 'background-position' => "#{self.x}px #{self.attr_y}px" + 'background-position' => "#{self.x}px #{self.y}px" } self.merge_opacity(r, opacity) if spot and spot != self r @@ -80,7 +100,7 @@ class GroundPicture < Peta::Element @@repeat_texts[self.repeat] end - def self.public_list_where + def self.public_list_where list 'panels.publish > 0' end