+ 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
+
+ def self.pickup_item_name
+ Picture.item_name
+ end
+
+ def self.pickup_column_name
+ self.pickup_item_name + '_id'
+ end
+
+ def pickup_id
+ # get :picture_id if head revision
+ self.attributes[self.pickup_column_name]
+ end
+
+ def y
+ self.attributes['y']
+ end
+
+ def self.by_author_list_includes
+ {
+ :panel => {
+ :author => {}
+ }
+ }
+ end
+
+ def self.has_picture?
+ true
+ end
+
+ def supply_default
+ self.x = 0
+ self.y = 0
+ if self.picture
+ self.width = self.picture.width
+ self.height = self.picture.height
+ end
+ if self.panel
+ self.t = self.panel.new_t
+ self.z = self.panel.new_z
+ end
+ end
+
+ def overwrite pid
+ self.panel_id = pid
+ end
+