X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fmodels%2Fcomic.rb;h=5b7f9dc111606326fd59e61d0ff9dbdedbf06de9;hb=31124ac1df4b11438308bb83525753b3e40e355a;hp=957fc568ad921b21459fa31ab8c3d6bb17443c20;hpb=0a341d917489add6967a07bbc8e48d8efd75b5c7;p=pettanr%2Fpettanr.git diff --git a/app/models/comic.rb b/app/models/comic.rb index 957fc568..5b7f9dc1 100644 --- a/app/models/comic.rb +++ b/app/models/comic.rb @@ -1,5 +1,6 @@ #コミック -class Comic < Pettanr::Content +class Comic < Peta::Content + load_manifest has_many :stories, :order => 't' belongs_to :author @@ -7,22 +8,28 @@ class Comic < Pettanr::Content validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1} validates :author_id, :presence => true, :numericality => true, :existence => {:both => false} - @@valid_encode_columns += ['title', 'description'] - @@visible_count_options = {:conditions => 'visible > 0'} - #@@filer = Pettanr::Cross::Filer.new self.item_name, cross + def self.visible_count_options + {:conditions => 'visible > 0'} + end def supply_default self.visible = 0 if self.visible.blank? end - def overwrite au - return false unless au - self.author_id = au.id + def overwrite operators + return false unless operators.author + self.author_id = operators.author.id end def visible? operators - super - self.visible > 0 + case super + when nil # super return + return true + when false + return false + else + self.visible > 0 + end end def comic_stories_count @@ -32,7 +39,7 @@ class Comic < Pettanr::Content def symbol_filename end - def self.list_where + def self.public_list_where 'comics.visible > 0' end @@ -40,30 +47,6 @@ class Comic < Pettanr::Content 'comics.updated_at desc' end - def self.mylist_where me - ['comics.author_id = ?', me.id] - end - - def self.mylist_order - 'comics.updated_at desc' - end - - def self.himlist_where anybody - ['comics.author_id = ? and comics.visible > 0', anybody.id] - end - - def self.himlist_order - 'comics.updated_at desc' - end - - def self.list_by_author_where author_id - ['comics.author_id = ?', author_id] - end - - def self.list_by_author author_id, roles, page = 1, page_size = self.default_page_size - self.where(self.list_by_author_where(author_id)).includes(self.list_opt).order('comics.updated_at desc').offset((page -1) * page_size).limit(page_size) - end - def self.list_opt {:stories => {}, :author => {} } end @@ -80,6 +63,11 @@ class Comic < Pettanr::Content {:include => {:stories => {}, :author => {}} } end + def tag_attributes column = nil, opt = {} + { + } + end + def destroy_with_story res = false Comic.transaction do