1 class ComicStory < Peta::Leaf
7 validates :comic_id, :presence => true, :numericality => true, :existence => {:both => false}
8 validates :story_id, :presence => true, :numericality => true, :existence => {:both => false}
9 validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
10 validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
18 def overwrite operators
19 return false unless operators.author
20 self.author_id = operators.author.id
28 I18n.t('comic_stories.show.t', :t => self.disp_t)
32 self.disp_t_by_text + ':' + self.story.title
35 def self.public_list_where
47 def self.list_json_opt
63 return nil if self.story_id == nil or self.comic_id == nil
64 self.comic.own?(operators) and self.story.own?(operators)
67 def store operators, old_t = nil
69 self.class.transaction do
70 case self.allow? operators
74 raise ActiveRecord::Forbidden
78 raise ActiveRecord::Rollback unless res
79 res = self.class.validate_t(self.comic_id)
81 self.errors.add :t, 'unserialized'
82 raise ActiveRecord::Rollback