OSDN Git Service

t#29061/t#29089/t#29076:add mylist. modify panel picture
[pettanr/pettanr.git] / app / models / panel.rb
index 56cd5b5..4328e91 100644 (file)
@@ -141,7 +141,7 @@ class Panel < ActiveRecord::Base
   def self.list_opt
     {:include => {
       :panel_pictures => {
-        :resource_picture => {:artist => {}, :license => {}}
+        :picture => {:artist => {}, :license => {}}
       }, 
       :speech_balloons => {:balloons => {}, :speeches => {}},
       :author => {}
@@ -151,13 +151,19 @@ class Panel < ActiveRecord::Base
   def self.list_json_opt
     {:include => {
       :panel_pictures => {
-        :resource_picture => {:artist => {}, :license => {}}
+        :picture => {:artist => {}, :license => {}}
       }, 
       :speech_balloons => {:balloons => {}, :speeches => {}},
       :author => {}
     }}
   end
   
+  def self.mylist au, opt = {}, page = 1, panel_page_size = Author.default_panel_page_size
+    opt.merge!(self.list_opt) unless opt[:include]
+    opt.merge!({:conditions => ['panels.author_id = ?', au.id], :order => 'panels.updated_at desc', :limit => panel_page_size, :offset => (page -1) * page_size})
+    Panel.find(:all, opt)
+  end
+  
   def self.show rid, au, opt = {}
     r = Panel.find(rid, :include => self.show_include_opt(opt))
     raise ActiveRecord::Forbidden unless r.visible?(au)
@@ -173,7 +179,7 @@ class Panel < ActiveRecord::Base
   def self.show_include_opt opt = {}
     res = {
       :panel_pictures => {
-        :resource_picture => {:artist => {}, :license => {}}
+        :picture => {:artist => {}, :license => {}}
       }, 
       :speech_balloons => {:balloons => {}, :speeches => {}},
       :author => {}
@@ -185,7 +191,7 @@ class Panel < ActiveRecord::Base
   def self.show_json_include_opt
     {:include => {
       :panel_pictures => {
-        :resource_picture => {:artist => {}, :license => {}}
+        :picture => {:artist => {}, :license => {}}
       }, 
       :speech_balloons => {:balloons => {}, :speeches => {}},
       :author => {}