OSDN Git Service

rails upgrade to 4 for js
[pettanr/pettanr.git] / app / models / resource_picture.rb
index 3488ab0..521a071 100644 (file)
@@ -24,6 +24,30 @@ class ResourcePicture < Peta::Content
   validates :license_group_settings, :boost => {:boost_name => :license_group}
   validates :credit_picture_settings, :boost => {:boost_name => :credit_picture}
   
+  scope :find_index, -> do
+    self.all
+  end
+  
+  scope :find_private, -> (operators) do 
+    where(artist_id: operators.artist.id)
+  end
+  
+  scope :find_by_original_picture, -> (original_picture_id) do 
+    find_index.where(original_picture_id: original_picture_id)
+  end
+  
+  scope :find_by_license_group, -> (license_group_id) do 
+    find_index.where(license_group_id: license_group_id)
+  end
+  
+  scope :find_by_license, -> (license_id) do 
+    find_index.where(license_id: license_id)
+  end
+  
+  scope :find_by_artist, -> (artist_id) do 
+    find_index.where(artist_id: artist_id)
+  end
+  
   def self.pickup_item_name
     Picture.item_name
   end