},\r
},\r
play: {\r
- type: 'filter',\r
+ type: 'play',\r
args: {\r
filter_item_name: 'scroll',\r
- item_wheres: ['index'],\r
- list_wheres: ['play'],\r
+ wheres: ['index', 'play'],\r
},\r
},\r
},\r
},\r
},\r
play: {\r
- type: 'public',\r
+ type: 'play',\r
+ args: {\r
+ filter_item_name: 'comic',\r
+ wheres: ['index', 'play'],\r
+ },\r
},\r
},\r
},\r
type: 'filter',\r
},\r
play: {\r
- type: 'public',\r
+ type: 'play',\r
+ args: {\r
+ filter_item_name: 'story',\r
+ wheres: ['index', 'play'],\r
+ },\r
},\r
},\r
},\r
index: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
},\r
scrolls: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
scroll_panels: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
comics: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
comic_stories: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
stories: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
story_sheets: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
sheets: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
sheet_panels: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
panels: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
panel_pictures: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
speech_balloons: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
speeches: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
balloons: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
ground_pictures: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
ground_colors: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
original_pictures: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
resource_pictures: {\r
type: 'public',\r
args: {\r
- item_wheres: ['index'],\r
- list_wheres: ['private'],\r
+ wheres: ['index', 'private'],\r
},\r
},\r
},\r
Artist.find( :first, :conditions => ['author_id = ?', author.id])
end
- def self.index_list_where
+ def self.index_list_where list
'artists.provider_id is null'
end
self.speech_balloon.speech_balloon_template.symbol_option
end
- def self.public_list_where
+ def self.public_list_where list
'panels.publish > 0'
end
def symbol_filename
end
- def self.public_list_where
+ def self.public_list_where list
'comics.visible > 0'
end
self.disp_t_by_text + ':' + self.story.title
end
- def self.public_list_where
+ def self.public_list_where list
'comics.visible > 0'
end
r
end
- def self.public_list_where
+ def self.public_list_where list
'panels.publish > 0'
end
@@repeat_texts[self.repeat]
end
- def self.public_list_where
+ def self.public_list_where list
'panels.publish > 0'
end
self.license_group.caption + '/' + self.caption
end
- def self.index_list_where
+ def self.index_list_where list
''
end
}
end
- def self.public_list_where
+ def self.public_list_where list
'panels.publish > 0'
end
self.picture.symbol_option
end
- def self.public_list_where
+ def self.public_list_where list
'panels.publish > 0'
end
end
end
- def self.public_list_where
+ def self.public_list_where list
'scrolls.visible > 0'
end
self.author_id = operators.author.id
end
- def self.public_list_where
+ def self.public_list_where list
'scrolls.visible > 0'
end
def symbol_filename
end
- def self.public_list_where
+ def self.public_list_where list
'sheets.visible > 0'
end
@@text_align_texts[self.text_align]
end
- def self.public_list_where
+ def self.public_list_where list
'panels.publish > 0'
end
self.speech_balloon_template.symbol_option
end
- def self.public_list_where
+ def self.public_list_where list
'panels.publish > 0'
end
end
end
- def self.public_list_where
+ def self.public_list_where list
'stories.visible > 0'
end
self.t = nil
end
- def self.public_list_where
+ def self.public_list_where list
'stories.visible > 0'
end
ManifestBase.require_modules "local_manifest/list_group/list/",
- %w|base public system_resource filter through_filter foreign_filter|
+ %w|base public play system_resource filter through_filter foreign_filter|
module LocalManifest
module ListGroupModule
def self.types
{
- 'public' => PublicList, 'system_resource' => SystemResourceList,
+ 'public' => PublicList, 'play' => PlayList, 'system_resource' => SystemResourceList,
'filter' => FilterList, 'through_filter' => ThroughFilterList, 'foreign_filter' => ForeignFilterList
}
end
module ListGroupModule
module ListModule
class Base < ManifestBase::TypeNameArgs
- attr :list_wheres, :includes
+ attr :wheres, :includes
def set_default
super
- @args['list_wheres'] ||= []
@args['includes'] ||= {}
end
def init
super
- @item_wheres = @args['item_wheres']
- @list_wheres = @args['list_wheres']
+ @wheres = @args['wheres'] || (self.model.content? ? ['index', 'public'] : ['index'])
@includes = ManifestBase.load_type_args self, @args, 'includes', IncludeFactory
end
- def item_wheres
- return @item_wheres if @item_wheres
- @item_wheres = @args['item_wheres'] || (self.model.content? ? ['index', 'public'] : ['index'])
- end
-
def model_manifest
::Manifest.manifest.models[self.item_name]
end
super
@filter_item_name = @args['filter_item_name']
@filter_key = @args['filter_key']
+ @wheres.push('filter') unless @wheres.include?('filter')
end
end
--- /dev/null
+module LocalManifest
+ module ListGroupModule
+ module ListModule
+ class PlayList < Base
+ attr :filter_item_name, :filter_key
+
+ def set_default
+ super
+ #@args['filter_item_name'] ||= @name.gsub(/^by_/, '')
+ @args['filter_key'] ||= @args['filter_item_name'] + '_id'
+ end
+
+ def init
+ super
+ @filter_item_name = @args['filter_item_name']
+ @filter_key = @args['filter_key']
+ end
+
+ end
+
+ end
+ end
+end
@list_group_manifest = LocalManifest.manifest.list_groups[@list_group_name]
@list_manifest = @list_group_manifest.lists[@list_name]
- @item_wheres = @list_manifest.item_wheres
- @list_wheres = @list_manifest.list_wheres
+ @wheres = @list_manifest.wheres
@includes = @list_manifest.includes
@controller_name = @list_group_name
self.order + ' ' + self.direction
end
- def where_condition
- @item_wheres.map {|key| @model.__send__(key + '_list_where')}.compact.join(' and ')
- end
-
def include_hash
@includes.includes
end
def arel
- r = @model.where(self.where_condition)
- @list_wheres.each do |key|
- r = r.where(@model.__send__(key + '_list_where', self))
+ r = @model
+ @wheres.each do |key|
+ n = key + '_list_where'
+ r = r.where(@model.respond_to?(n) ? @model.__send__(n, self) : self.__send__(n))
end
r.includes(
self.include_hash
end
end
+ def private_list_where
+ owner_model = if @model.element?
+ @model.root_model
+ else
+ @model
+ end
+ case owner_model.owner_type
+ when :author
+ operator = @operators.author
+ when :artist
+ operator = @operators.artist
+ end
+ [owner_model.table_name + '.' + owner_model.owner_type.to_s + '_id = ?', operator.id]
+ end
+
end
end
super
end
- def where_condition
- w = super
- w += ' and ' unless w.blank?
- [w + @table_name + '.' + @filter_key + ' = ?', self.filter_id]
+ def filter_list_where
+ [@table_name + '.' + @filter_key + ' = ?', self.filter_id]
end
def include_hash
@filter_table_name = ::Manifest.manifest.models[@filter_item_name].classify.table_name
end
- def where_condition
- w = super
- w += ' and ' unless w.blank?
- [w + @filter_table_name + '.id' + ' = ?', self.filter_id]
+ def filter_list_where
+ [@filter_table_name + '.id' + ' = ?', self.filter_id]
end
def include_hash
module Locmare
module ListGroupModule
- class PlayList < FilterList
+ class PlayList < Base
+ attr :filter_key, :filter_item_name
- def offset cnt, prm = nil
- offset = prm.to_i
- offset = cnt - 1 if offset >= cnt
- offset = cnt - offset.abs if offset < 0
- offset = 0 if offset < 0
- offset
+ def init
+ @binder_action = @action_manifest.original
+ @binder_controller = @binder_action.controller
+ @binder_model = Manifest.manifest.models[@binder_action.item_name]
+ @binder_model_class = @binder_model.classify
+ @binder_item = @binder_model_class.show(self.filter_id, @operators)
+
+ @wheres.delete('index') if @binder_item.own?(@operators)
+ @binder_list_group_manifest = LocalManifest.manifest.list_groups[@binder_controller.name]
+ @binder_list_manifest = @binder_list_group_manifest.lists[@binder_action.name]
+ @filter_key = @binder_list_manifest.filter_key
+ @filter_item_name = @binder_list_manifest.filter_item_name
+ @filter_model = ::Manifest.manifest.models[@filter_item_name].classify
+ @filter_table_name = @filter_model.table_name
+ super
end
- def limit prm
- prm ||= self.default_page_size
- count = prm.to_i
- count = self.max_page_size if count > self.max_page_size
- count = self.default_page_size if count < 1
- count
+ def play_list_where
+ [@table_name + '.' + @filter_key + ' = ?', self.filter_id]
end
- def where_condition filter_item_id, my_play = false
- base_where = if my_play
- ''
- else
- w = self.base_where_condition
- w += ' and ' unless w.blank?
- w
- end
- [base_where + @table_name + '.' + @filter_key + ' = ?', filter_item_id]
- end
-
- def items operators, options, offset, limit
- filter_item_id = options[:id]
- my_play = options[:my_play]
- @model.where(self.where_condition(filter_item_id, my_play)).includes(self.include_hash).order(self.order).offset(offset).limit(limit)
- end
-
- def count operators, options
- filter_item_id = options[:id]
- my_play = options[:my_play]
- @model.where(self.where_condition(filter_item_id, my_play)).includes(self.include_hash).count
- end
-
- def open operators, options
- count = self.count operators, options
- if options[:offset]
- offset = self.offset count, options[:offset]
- page_size = self.limit options[:count]
- pg = nil
- else
- page = self.page_number(options[:page])
- page_size = self.page_size options[:page_size]
- offset = (page -1) * page_size
- pg = self.paginate count, page, page_size
- end
- items = self.items operators, options, offset, page_size
- self.boost items
- ListResult.new self, items, count, pg, operators, options
+ def include_hash
+ w = super
+ w.merge!({@filter_item_name => {} }) unless w[@filter_item_name]
+ w
end
end
{@through => {@filter_item_name => {}} }
end
- def where_condition
- w = super
- w += ' and ' unless w.blank?
- [w + @filter_table_name + '.id' + ' = ?', self.filter_id]
+ def filter_list_where
+ [@filter_table_name + '.id' + ' = ?', self.filter_id]
end
end
operators.__send__ self.owner_type
end
- def self.public_list_where
+ def self.public_list_where list
nil
end
- def self.private_list_where list
- owner_model = if self.element?
- self.root_model
- else
- self
- end
- case owner_model.owner_type
- when :author
- operator = list.operators.author
- when :artist
- operator = list.operators.artist
- end
- [owner_model.table_name + '.' + owner_model.owner_type.to_s + '_id = ?', operator.id]
- end
-
def self.edit content_id, operators
content = self.find content_id, self.show_opt
raise ActiveRecord::Forbidden unless content.own?(operators)
self.my_peta.extend_column? column_name
end
- def self.index_list_where
+ def self.index_list_where list
nil
end
self.table_name + '.t'
end
- def self.play_list_where list
- [list.table_name + '.' + list.filter_key + ' = ?', list.filter_id]
- end
-
def self.new_t binder_id
r = self.max_t(binder_id)
r.blank? ? 0 : r.to_i + 1
}\r
},\r
"play": {\r
- "type": "filter",\r
+ "type": "play",\r
"args": {\r
"filter_item_name": "scroll",\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"play"\r
]\r
}\r
"index": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"scrolls": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"scroll_panels": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"comics": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"comic_stories": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"stories": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"story_sheets": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"sheets": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"sheet_panels": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"panels": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"panel_pictures": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"speech_balloons": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"speeches": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"balloons": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"ground_pictures": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"ground_colors": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"original_pictures": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r
"resource_pictures": {\r
"type": "public",\r
"args": {\r
- "item_wheres": [\r
- "index"\r
- ],\r
- "list_wheres": [\r
+ "wheres": [\r
+ "index",\r
"private"\r
]\r
}\r