belongs_to :resource_picture
# belongs_to :background_picture, :class_name => 'ResourcePicture'
has_many :panel_pictures, :dependent => :destroy
- has_many :balloons, :dependent => :destroy
+ has_many :speech_balloons, :dependent => :destroy
accepts_nested_attributes_for :panel_pictures, :allow_destroy => true
- accepts_nested_attributes_for :balloons, :allow_destroy => true
+ accepts_nested_attributes_for :speech_balloons, :allow_destroy => true
# validates :comic_id, :presence => true, :numericality => true, :existence => true, :uniqueness => {:scope => :t}
validates :resource_picture_id, :numericality => {:allow_blank => true}
validates :author_id, :presence => true, :numericality => true, :existence => true
def supply_default au
+ return false unless au
c = self.comic_id ? Comic.show(self.comic_id, au) : nil
if c
self.width = c.width if self.width.blank?
#更新する時にPanelIDをチェックしとかないと勝手に所属先を変えられるゾ!?
- def vdt_save
+ def store
f = nil
f = Panel.find_t(self.comic_id, self.t) if self.t
if f
:panel_pictures => {
:resource_picture => {:artist => {}, :license => {}}
},
- :balloons => {:speeches => {}},
+ :speech_balloons => {:balloons => {}, :speeches => {}},
:author => {}
}}
end
def self.list_json_opt
{:include => {
- :comic => :author,
+ :comic => {:author => {}},
:panel_pictures => {
:resource_picture => {:artist => {}, :license => {}}
},
- :balloons => {:speeches => {}},
+ :speech_balloons => {:balloons => {}, :speeches => {}},
:author => {}
}}
end
:panel_pictures => {
:resource_picture => {:artist => {}, :license => {}}
},
- :balloons => {:speeches => {}},
+ :speech_balloons => {:balloons => {}, :speeches => {}},
:author => {}
}
res.merge!(opt[:include]) if opt[:include]
def self.show_json_include_opt
{:include => {
- :comic => :author,
+ :comic => {:author => {}},
:panel_pictures => {
:resource_picture => {:artist => {}, :license => {}}
},
- :balloons => {:speeches => {}},
+ :speech_balloons => {:balloons => {}, :speeches => {}},
:author => {}
}}
end
def to_json_play
self.to_json :methods => :panel_elements
end
+
+ def self.visible_count
+ Panel.count
+ end
+
end