args: {\r
param_id: 'none',\r
max_page_size: -1,\r
+ order: 't',\r
+ direction: 1\r
},\r
},\r
by_panel: {\r
args: {\r
param_id: 'none',\r
max_page_size: -1,\r
+ order: 't',\r
+ direction: 1\r
},\r
},\r
by_system_picture: {\r
args: {\r
param_id: 'none',\r
max_page_size: -1,\r
+ order: 't',\r
+ direction: 1\r
},\r
},\r
by_resource_picture: {\r
args: {\r
param_id: 'none',\r
max_page_size: -1,\r
+ order: 'name',\r
+ direction: 1\r
},\r
},\r
by_license_group: {\r
type: 'list',\r
args: {\r
param_id: 'suffix',\r
+ order: 'name',\r
+ direction: 1\r
},\r
},\r
by_system_picture: {\r
scrolls: {\r
type: 'list',\r
args: {\r
- item_name: 'scroll',\r
- param_id: 'none',\r
+ alias: 'scrolls.index',\r
},\r
},\r
scroll_panels: {\r
type: 'list',\r
args: {\r
- item_name: 'scroll_panel',\r
- param_id: 'none',\r
+ alias: 'scroll_panels.index',\r
},\r
},\r
comics: {\r
type: 'list',\r
args: {\r
- item_name: 'comic',\r
- param_id: 'none',\r
+ alias: 'comics.index',\r
},\r
},\r
comic_stories: {\r
type: 'list',\r
args: {\r
- item_name: 'comic_story',\r
- param_id: 'none',\r
+ alias: 'comic_stories.index',\r
},\r
},\r
stories: {\r
type: 'list',\r
args: {\r
- item_name: 'story',\r
- param_id: 'none',\r
+ alias: 'stories.index',\r
},\r
},\r
story_sheets: {\r
type: 'list',\r
args: {\r
- item_name: 'story_sheet',\r
- param_id: 'none',\r
+ alias: 'story_sheets.index',\r
},\r
},\r
sheets: {\r
type: 'list',\r
args: {\r
- item_name: 'sheet',\r
- param_id: 'none',\r
+ alias: 'sheets.index',\r
},\r
},\r
sheet_panels: {\r
type: 'list',\r
args: {\r
- item_name: 'sheet_panel',\r
- param_id: 'none',\r
+ alias: 'sheet_panels.index',\r
},\r
},\r
panels: {\r
type: 'list',\r
args: {\r
- item_name: 'panel',\r
- param_id: 'none',\r
+ alias: 'panels.index',\r
},\r
},\r
panel_pictures: {\r
type: 'list',\r
args: {\r
- item_name: 'panel_picture',\r
- param_id: 'none',\r
+ alias: 'panel_pictures.index',\r
},\r
},\r
speech_balloons: {\r
type: 'list',\r
args: {\r
- item_name: 'speech_balloon',\r
- param_id: 'none',\r
+ alias: 'speech_balloons.index',\r
},\r
},\r
speeches: {\r
type: 'list',\r
args: {\r
- item_name: 'speech',\r
- param_id: 'none',\r
+ alias: 'speeches.index',\r
},\r
},\r
balloons: {\r
type: 'list',\r
args: {\r
- item_name: 'balloon',\r
- param_id: 'none',\r
+ alias: 'balloons.index',\r
},\r
},\r
ground_pictures: {\r
type: 'list',\r
args: {\r
- item_name: 'ground_picture',\r
- param_id: 'none',\r
+ alias: 'ground_pictures.index',\r
},\r
},\r
ground_colors: {\r
type: 'list',\r
args: {\r
- item_name: 'ground_color',\r
- param_id: 'none',\r
+ alias: 'ground_colors.index',\r
},\r
},\r
original_pictures: {\r
type: 'list',\r
args: {\r
- item_name: 'original_picture',\r
- param_id: 'none',\r
+ alias: 'original_pictures.index',\r
},\r
},\r
resource_pictures: {\r
type: 'list',\r
args: {\r
- item_name: 'resource_picture',\r
- param_id: 'none',\r
+ alias: 'resource_pictures.index',\r
},\r
},\r
},\r
},\r
},\r
play: {\r
- type: 'play',\r
+ type: 'filter',\r
+ args: {\r
+ filter_item_name: 'scroll',\r
+ item_wheres: ['index'],\r
+ list_wheres: ['play'],\r
+ },\r
},\r
},\r
},\r
},\r
},\r
play: {\r
- type: 'play',\r
+ type: 'public',\r
},\r
},\r
},\r
type: 'filter',\r
},\r
play: {\r
- type: 'play',\r
+ type: 'public',\r
},\r
},\r
},\r
type: 'filter',\r
},\r
play: {\r
- type: 'play',\r
+ type: 'public',\r
},\r
},\r
},\r
original_pictures: {\r
lists: {\r
index: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
},\r
},\r
lists: {\r
index: {\r
type: 'public',\r
+ args: {\r
+ after_method_name: 'enable',\r
+ },\r
},\r
by_system_picture: {\r
type: 'filter',\r
home: {\r
lists: {\r
scrolls: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
scroll_panels: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
comics: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
comic_stories: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
stories: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
story_sheets: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
sheets: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
sheet_panels: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
panels: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
panel_pictures: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
speech_balloons: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
speeches: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
balloons: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
ground_pictures: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
ground_colors: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
original_pictures: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
resource_pictures: {\r
- type: 'private',\r
+ type: 'public',\r
+ args: {\r
+ item_wheres: ['index'],\r
+ list_wheres: ['private'],\r
+ },\r
},\r
},\r
},\r
set_model
@my_list_model = Manifest.manifest.models[@my_action.item_name]
@my_list_model_class = @my_list_model.classify
- @list = Locmare::ListGroup.list @my_controller.name, @my_action.action_name, @operators, params
+ @list = Locmare::ListGroup.list @my_action.controller.name, @my_action.action_name, @operators, params
end
def filer_list
def set_play
set_list
- @binder_controller = Manifest.manifest.controllers[params[:controller].to_s]
- @binder_action = @my_controller.actions[params[:action].to_s]
+ @binder_action = @my_action.original
+ @binder_controller = @binder_action.controller
@binder_model = Manifest.manifest.models[@binder_action.item_name]
@binder_model_class = @binder_model.classify
@item = @binder_model_class.show(params[:id], @operators)
def play_list
@options = params
- @options[:my_play] = @item.own?(@operators)
- list_result = @list.open(@operators)
- @items = list_result.items
- @count = list_result.count
- @pager = list_result.paginate
+ if @item.own?(@operators)
+ @list.item_wheres = []
+ @list.list_wheres = ['private', 'play']
+ end
+ @items = @list.items #.map {|sp| sp.root }
+ @count = @list.total
+ @pager = @list.page_status.pager
end
def set_show
}
end
- def assist_items controller_name, list_name
- list = Locmare::ListGroup.list controller_name, list_name, @operators, {:id => @item.id, :page => 1, :page_size => 5}
- list_result = list.open(@operators)
- list_result.items
+ def assist_items controller_name, action_name
+ list = Locmare::ListGroup.list controller_name, action_name, @operators, {:id => @item.id, :page => 1, :page_size => 5}
+ list.items
end
def set_image(file)
private
def panel_list
set_list
- list_result = @list.open(@operators)
- @items = list_result.items
- @pager = list_result.paginate
+ @items = @list.items
+ @pager = @list.page_status.pager
respond_to do |format|
format.html
format.json { render json: @items.map{|i| i.attributes}.to_json }
jsn = JSON.parse(params[:json])
end
@prm = params[:panel] || jsn
- self.model.fold_extend_settings @prm
+ @item.class.fold_extend_settings @prm
@item.attributes = @prm
- @item.refresh
+ # @item.refresh
respond_to do |format|
- if @item.store @item.packed_attributes, @operators
+ if @item.store @prm, @operators
updated_html_format format
updated_json_format format
else
before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
else
before_filter :authenticate_reader, :only => [
- :index, :show, :by_panel, :by_scroll, :by_author, :play :play
+ :index, :show, :by_panel, :by_scroll, :by_author
]
before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
filer_list
end
- def play
- filer_list
- end
-
def show
set_show
respond_to do |format|
Artist.find( :first, :conditions => ['author_id = ?', author.id])
end
- def self.list_where
+ def self.index_list_where
'artists.provider_id is null'
end
self.license_group.caption + '/' + self.caption
end
- def self.list_where
+ def self.index_list_where
''
end
- def self.list_order
- 'licenses.name'
- end
-
def self.show_opt
{:include => {:license_group => {}}}
end
self.tmb_opt_img_tag
end
- def self.list_order
- 'resource_pictures.updated_at desc'
- end
-
- def self.list_where
- ''
- end
-
def self.list_opt
{:license => {}, :artist => {}, :picture => {} }
end
<h2><%= t('panels.empty') %></h2>
<% else %>
<h2><%= link_to t('panels.filer'), main_app.panels_path(:mode => 'filer', :page => params[:page], :page_size => params[:page_size]) %></h2>
- <%= paginate(@pager) %>
+ <%= render @pager.template_name, :pager => @pager %>
<% @items.each do |panel| %>
<%= render 'body', :panel => panel, :operators => @operators, :spot => nil %>
<%= render 'panels/footer', :panel => panel, :operators => @operators %>
<% end %>
+ <%= render @pager.template_name, :pager => @pager %>
<%= render 'panels/licensed_pictures', :licensed_pictures => Panel.licensed_pictures(@items) %>
- <%= paginate(@pager) %>
<% end %>
<% if @items.empty? -%>
<h2><%= t('scrolls.play.empty') %></h2>
<% else %>
- <%= paginate(@pager) %>
+ <%# paginate(@pager) %>
<% @items.each do |scroll_panel| %>
<% if scroll_panel.panel -%>
<%= render 'panels/body', :panel => scroll_panel.panel, :operators => @operators, :spot => nil %>
<%= render 'scroll_panels/footer', :scroll_panel => scroll_panel, :operators => @operators %>
<% end %>
<%= render 'panels/licensed_pictures', :licensed_pictures => ScrollPanel.licensed_pictures(@items) %>
- <%= paginate(@pager) %>
+ <%# paginate(@pager) %>
<% end %>
<% if @item.own? @operators -%>
<h3 id="editor"><%= t('editor') -%></h3>
ManifestBase.require_modules "local_manifest/list_group/list/",
- %w|base public private system_resource filter through_filter foreign_filter play|
+ %w|base public system_resource filter through_filter foreign_filter|
module LocalManifest
module ListGroupModule
def self.types
{
- 'public' => PublicList, 'private' => PrivateList, 'system_resource' => SystemResourceList,
- 'filter' => FilterList, 'through_filter' => ThroughFilterList, 'foreign_filter' => ForeignFilterList,
- 'play' => PlayList
+ 'public' => PublicList, 'system_resource' => SystemResourceList,
+ 'filter' => FilterList, 'through_filter' => ThroughFilterList, 'foreign_filter' => ForeignFilterList
}
end
ManifestBase.require_modules "local_manifest/list_group/list/",
- %w|where includes|
+ %w|includes|
module LocalManifest
module ListGroupModule
module ListModule
class Base < ManifestBase::TypeNameArgs
- attr :where, :includes
+ attr :list_wheres, :includes
def set_default
super
- @args['where'] ||= {}
+ @args['list_wheres'] ||= []
@args['includes'] ||= {}
end
def init
super
- @where = ManifestBase.load_type_args self, @args, 'where', WhereFactory
+ @item_wheres = @args['item_wheres']
+ @list_wheres = @args['list_wheres']
@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
+++ /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
+++ /dev/null
-module LocalManifest
- module ListGroupModule
- module ListModule
- class PrivateList < Base
- end
-
- end
- end
-end
+++ /dev/null
-ManifestBase.require_modules "local_manifest/list_group/list/where/",
- %w|base method auto|
-
-module LocalManifest
- module ListGroupModule
- module ListModule
- class WhereFactory < ManifestBase::Factory
- include WhereModule
-
- def self.types
- {
- 'method' => WhereMethod, 'auto' => WhereAuto
- }
- end
-
- def self.default_type
- 'auto'
- end
-
- end
- end
- end
-end
+++ /dev/null
-module LocalManifest
- module ListGroupModule
- module ListModule
- module WhereModule
- class WhereAuto < Base
- def set_default
- super
- end
-
- def init
- super
- end
-
- def method_name
- if self.model.content?
- 'public_list_where'
- else
- 'list_where'
- end
- end
-
- def conditions
- yield self.method_name
- end
-
- end
-
- end
- end
- end
-end
+++ /dev/null
-module LocalManifest
- module ListGroupModule
- module ListModule
- module WhereModule
- class Base < ManifestBase::TypeArgs
-
- def set_default
- super
- end
-
- def init
- super
- end
-
- def item_name
- @parent.item_name
- end
-
- def list_name
- @parent.name
- end
-
- def model
- @parent.model
- end
-
- end
-
- end
- end
- end
-end
+++ /dev/null
-module LocalManifest
- module ListGroupModule
- module ListModule
- module WhereModule
- class WhereMethod < Base
- attr :method_name
-
- def set_default
- super
- @args['method_name'] ||= @parent.name + '_list_where'
- end
-
- def init
- super
- @method_name = @args['method_name']
- end
-
- def conditions
- yield @method_name
- end
-
- end
-
- end
- end
- end
-end
def url
controller_manifest = @item.class.my_controller
action_manifest = controller_manifest.actions[@link_manifest.action_name]
- action_manifest.url({'id' => @item.id.to_s})
+ mani = action_manifest.original || action_manifest
+ mani.url({'id' => @item.id.to_s})
end
end
require_dependency "locmare/list_group/list/base"
require_dependency "locmare/list_group/list/public"
-require_dependency "locmare/list_group/list/private"
require_dependency "locmare/list_group/list/system_resource"
require_dependency "locmare/list_group/list/filter"
require_dependency "locmare/list_group/list/through_filter"
def self.types
{
- 'public' => PublicList, 'private' => PrivateList, 'system_resource' => SystemResourceList,
+ 'public' => PublicList, 'system_resource' => SystemResourceList,
'filter' => FilterList, 'through_filter' => ThroughFilterList, 'foreign_filter' => ForeignFilterList,
'play' => PlayList
}
@list.max_page_size
end
+ def mod
+ @total % self.limit
+ end
+
+ def adjust
+ self.mod == 0 ? 0 : 1
+ end
+
def total_page
- (@total / self.limit) + 1
+ (@total / self.limit) + self.adjust
end
def pageable?
@template_name = @template_dir + 'default'
@controller = Manifest.manifest.controllers[@options['controller'].to_s]
@action = @controller.actions[@options['action'].to_s]
+ @action = @action.original if @action.original
@current_page = @page_status.page
@per_page = @page_status.limit
module Locmare
module ListGroupModule
class Base
- attr :list_group_name, :list_name, :options, :item_name,
- :controller_manifest, :action_manifest, :list_manifest, :model,
- :page_status
+ attr_accessor :list_group_name, :list_name, :operators, :options, :item_name,
+ :controller_manifest, :action_manifest, :list_manifest, :model, :table_name,
+ :page_status, :item_wheres, :list_wheres
def initialize list_group_name, list_name, operators, options = {}
@list_group_name = list_group_name
@list_group_manifest = LocalManifest.manifest.list_groups[@list_group_name]
@list_manifest = @list_group_manifest.lists[@list_name]
- @where = @list_manifest.where
+ @item_wheres = @list_manifest.item_wheres
+ @list_wheres = @list_manifest.list_wheres
@includes = @list_manifest.includes
@controller_name = @list_group_name
def init
@page_status = LibModule::PageStatus.load self, self.total, @options
- self.boost items
end
def model_name
self.order + ' ' + self.direction
end
- def base_where_condition
- method_name = @where.conditions do |name|
- name
- end
- @model.__send__ method_name
- end
-
def where_condition
- base_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))
+ end
+ r.includes(
+ self.include_hash
+ )
+ end
+
def items
return [] unless @page_status
- @items ||= @model.where(
- self.where_condition
- ).includes(
- self.include_hash
- ).order(
+ @items ||= self.arel.order(
self.order_by
).offset(@page_status.offset).limit(@page_status.limit)
+ self.boost
+ @items
end
def total
- @model.where(
- self.where_condition
- ).includes(
- self.include_hash
- ).count
+ self.arel.count
# return string : =>"25"
end
end
end
- def boost items
+ def boost
manifests = self.boost_manifests
- items.each do |item|
+ @items.each do |item|
manifests.each do |boost_manifest|
item.boost_manifest # ?
end
end
def where_condition
- w = self.base_where_condition
+ w = super
w += ' and ' unless w.blank?
[w + @table_name + '.' + @filter_key + ' = ?', self.filter_id]
end
end
def where_condition
- w = self.base_where_condition
+ w = super
w += ' and ' unless w.blank?
[w + @filter_table_name + '.id' + ' = ?', self.filter_id]
end
+++ /dev/null
-module Locmare
- module ListGroupModule
- class PrivateList < Base
-
- def init
- super
- end
-
- def where_condition
- 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
-
- def items
- @model.where(
- self.where_condition
- ).includes(
- self.include_hash
- ).order(
- self.order_by
- ).offset(@offset).limit(@limit)
- end
-
- def count
- @model.where(
- self.where_condition
- ).includes(
- self.include_hash
- ).count
- end
-
- end
-
- end
-end
end
def where_condition
- w = self.base_where_condition
+ w = super
w += ' and ' unless w.blank?
[w + @filter_table_name + '.id' + ' = ?', self.filter_id]
end
module ControllerModule
module ActionModule
class Base < ManifestBase::TypeNameArgs
- attr :param_id, :item_name, :action_name
+ attr :alias, :param_id, :item_name, :action_name, :original
def set_default
super
def init
super
@action_name = @name
+ @alias = @args['alias']
@item_name = @args['item_name']
@param_id = @args['param_id']
+ # source manifest of alias manifest
+ @original = @args['original']
+ end
+
+ def a_arg_names
+ []
+ end
+
+ def b_arg_names
+ ['item_name', 'param_id']
+ end
+
+ def controller
+ @parent
+ end
+
+ def alias_action
+ s = @alias.split('.')
+ c = ::Manifest.manifest.controllers[s[0]]
+ c.actions[s[1]]
end
def path_name
module ControllerModule
module ActionModule
class ActionList < Base
- attr :alias, :order, :direction, :default_page_size, :max_page_size
+ attr :order, :direction, :default_page_size, :max_page_size
def set_default
super
def init
super
- @alias = @args['alias']
@order = @args['order'] || 'updated_at'
@direction = @args['direction'].to_i
@default_page_size = @args['default_page_size']
@max_page_size = @args['max_page_size']
end
- def alias_action
- s = @alias.split('.')
- c = ::Manifest.manifest.controllers[s[0]]
- c.actions[s[1]]
+ def a_arg_names
+ super + ['order', 'direction', 'default_page_size', 'max_page_size']
end
end
end
@items = ManifestBase.load_type_name_args(self, @global_json, 'items', ItemFactory)
@controllers = Controller.load(self, @global_json, 'controllers')
+ self.replace_action_alias
@models = Model.load(self, @global_json, 'models')
end
@system_resources.init
end
+ def replace_action_alias
+ replaces = {}
+ @controllers.each do |controller_name, controller_manifest|
+ controller_manifest.actions.each do |action_name, action_manifest|
+ next unless action_manifest.alias
+ alias_action = action_manifest.alias_action
+ next unless alias_action.type == action_manifest.type
+ args = {}
+ action_manifest.a_arg_names.each do |name|
+ args[name] = action_manifest.__send__(name) || alias_action.__send__(name)
+ end
+ action_manifest.b_arg_names.each do |name|
+ args[name] = alias_action.__send__(name) || action_manifest.__send__(name)
+ end
+ args['original'] = action_manifest
+ json = {'type' => alias_action.type, 'args' => args}
+ new_action_manifest = ControllerModule::ActionFactory.factory(
+ controller_manifest, action_manifest.name, json, action_manifest.module_name
+ )
+ replaces[controller_name] ||= {}
+ replaces[controller_name][action_name] = new_action_manifest
+ end
+ end
+ replaces.each do |controller_name, controller|
+ controller.each do |action_name, action_manifest|
+ ::Manifest.manifest.controllers[controller_name].actions[action_name] = action_manifest
+ end
+ end
+ end
+
def load_models_manifest
@models.each do |model_name, model|
# skip extend model.
module ManifestBase
class TypeNameArgs
- attr :parent, :name, :json, :type, :module_name
+ attr :parent, :name, :json, :type, :args, :module_name
def initialize parent, name, json, module_name
@parent = parent
end
def self.public_list_where
- ''
+ 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
self.my_peta.extend_column? column_name
end
- def self.list_where
- ''
+ def self.index_list_where
+ nil
end
def self.list_opt
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": "play"\r
+ "type": "filter",\r
+ "args": {\r
+ "filter_item_name": "scroll",\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "play"\r
+ ]\r
+ }\r
}\r
}\r
},\r
}\r
},\r
"play": {\r
- "type": "play"\r
+ "type": "public"\r
}\r
}\r
},\r
"type": "filter"\r
},\r
"play": {\r
- "type": "play"\r
+ "type": "public"\r
}\r
}\r
},\r
"type": "filter"\r
},\r
"play": {\r
- "type": "play"\r
+ "type": "public"\r
}\r
}\r
},\r
"original_pictures": {\r
"lists": {\r
"index": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
}\r
}\r
},\r
"writing_formats": {\r
"lists": {\r
"index": {\r
- "type": "public"\r
+ "type": "public",\r
+ "args": {\r
+ "after_method_name": "enable"\r
+ }\r
},\r
"by_system_picture": {\r
"type": "filter"\r
"home": {\r
"lists": {\r
"scrolls": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"scroll_panels": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"comics": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"comic_stories": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"stories": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"story_sheets": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"sheets": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"sheet_panels": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"panels": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"panel_pictures": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"speech_balloons": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"speeches": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"balloons": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"ground_pictures": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"ground_colors": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"original_pictures": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
},\r
"resource_pictures": {\r
- "type": "private"\r
+ "type": "public",\r
+ "args": {\r
+ "item_wheres": [\r
+ "index"\r
+ ],\r
+ "list_wheres": [\r
+ "private"\r
+ ]\r
+ }\r
}\r
}\r
}\r
"type": "list",\r
"args": {\r
"param_id": "none",\r
- "max_page_size": -1\r
+ "max_page_size": -1,\r
+ "order": "t",\r
+ "direction": 1\r
}\r
},\r
"by_panel": {\r
"type": "list",\r
"args": {\r
"param_id": "none",\r
- "max_page_size": -1\r
+ "max_page_size": -1,\r
+ "order": "t",\r
+ "direction": 1\r
}\r
},\r
"by_system_picture": {\r
"type": "list",\r
"args": {\r
"param_id": "none",\r
- "max_page_size": -1\r
+ "max_page_size": -1,\r
+ "order": "t",\r
+ "direction": 1\r
}\r
},\r
"by_resource_picture": {\r
"type": "list",\r
"args": {\r
"param_id": "none",\r
- "max_page_size": -1\r
+ "max_page_size": -1,\r
+ "order": "name",\r
+ "direction": 1\r
}\r
},\r
"by_license_group": {\r
"type": "list",\r
"args": {\r
- "param_id": "suffix"\r
+ "param_id": "suffix",\r
+ "order": "name",\r
+ "direction": 1\r
}\r
},\r
"by_system_picture": {\r
"scrolls": {\r
"type": "list",\r
"args": {\r
- "item_name": "scroll",\r
- "param_id": "none"\r
+ "alias": "scrolls.index"\r
}\r
},\r
"scroll_panels": {\r
"type": "list",\r
"args": {\r
- "item_name": "scroll_panel",\r
- "param_id": "none"\r
+ "alias": "scroll_panels.index"\r
}\r
},\r
"comics": {\r
"type": "list",\r
"args": {\r
- "item_name": "comic",\r
- "param_id": "none"\r
+ "alias": "comics.index"\r
}\r
},\r
"comic_stories": {\r
"type": "list",\r
"args": {\r
- "item_name": "comic_story",\r
- "param_id": "none"\r
+ "alias": "comic_stories.index"\r
}\r
},\r
"stories": {\r
"type": "list",\r
"args": {\r
- "item_name": "story",\r
- "param_id": "none"\r
+ "alias": "stories.index"\r
}\r
},\r
"story_sheets": {\r
"type": "list",\r
"args": {\r
- "item_name": "story_sheet",\r
- "param_id": "none"\r
+ "alias": "story_sheets.index"\r
}\r
},\r
"sheets": {\r
"type": "list",\r
"args": {\r
- "item_name": "sheet",\r
- "param_id": "none"\r
+ "alias": "sheets.index"\r
}\r
},\r
"sheet_panels": {\r
"type": "list",\r
"args": {\r
- "item_name": "sheet_panel",\r
- "param_id": "none"\r
+ "alias": "sheet_panels.index"\r
}\r
},\r
"panels": {\r
"type": "list",\r
"args": {\r
- "item_name": "panel",\r
- "param_id": "none"\r
+ "alias": "panels.index"\r
}\r
},\r
"panel_pictures": {\r
"type": "list",\r
"args": {\r
- "item_name": "panel_picture",\r
- "param_id": "none"\r
+ "alias": "panel_pictures.index"\r
}\r
},\r
"speech_balloons": {\r
"type": "list",\r
"args": {\r
- "item_name": "speech_balloon",\r
- "param_id": "none"\r
+ "alias": "speech_balloons.index"\r
}\r
},\r
"speeches": {\r
"type": "list",\r
"args": {\r
- "item_name": "speech",\r
- "param_id": "none"\r
+ "alias": "speeches.index"\r
}\r
},\r
"balloons": {\r
"type": "list",\r
"args": {\r
- "item_name": "balloon",\r
- "param_id": "none"\r
+ "alias": "balloons.index"\r
}\r
},\r
"ground_pictures": {\r
"type": "list",\r
"args": {\r
- "item_name": "ground_picture",\r
- "param_id": "none"\r
+ "alias": "ground_pictures.index"\r
}\r
},\r
"ground_colors": {\r
"type": "list",\r
"args": {\r
- "item_name": "ground_color",\r
- "param_id": "none"\r
+ "alias": "ground_colors.index"\r
}\r
},\r
"original_pictures": {\r
"type": "list",\r
"args": {\r
- "item_name": "original_picture",\r
- "param_id": "none"\r
+ "alias": "original_pictures.index"\r
}\r
},\r
"resource_pictures": {\r
"type": "list",\r
"args": {\r
- "item_name": "resource_picture",\r
- "param_id": "none"\r
+ "alias": "resource_pictures.index"\r
}\r
}\r
}\r