class ComicsController < ApplicationController
if Manifest.manifest.magic_numbers['run_mode'] == 0
- before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
- before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
+ before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+ before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
else
- before_filter :authenticate_reader, :only => [
- :index, :show, :play, :by_story, :by_author, :count, :count_by_story, :count_by_author
+ before_action :authenticate_reader, :only => [
+ :index, :show, :play, :by_story, :by_author
]
- before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
- before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
- end
-
- def self.model
- Comic
+ before_action :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
+ before_action :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
end
def index
end
def by_story
- filer_list
+ filer_list param: params[:id]
end
def by_author
- filer_list
+ filer_list param: params[:id]
end
def show_html_format format
format.html {
- play_list = Locmare::ListGroup.list 'comic_story', 'play'
- @play_count = play_list.count(@operators,
- {:id => @item.id, :my_play => @item.own?(@operators)}
+ @play_list = Locmare::ListGroup.list(
+ 'comic_stories', 'by_comic', @operators,
+ {:id => @item.id, :page_size => -1} # set no limit options
)
}
end
end
def play
- @item = self.class.model.show(params[:id], @operators)
set_play
- @items = @list.items(@operators,
- {:id => params[:id], :my_play => @item.own?(@operators)},
- 0, -1 # no limit
- )
- @count = @items.count
- # no pager
+ @finder.per(-1) # no limit no pager
+ play_list
respond_to do |format|
format.html {
if @item.own? @operators
- @new_story_items = assist_items('story', 'private')
+ @new_story_items = assist_items('home', 'stories', finder: :find_private, param: @operators)
end
}
- format.json { render json: @items.to_json }
+ list_json_format @finder, format
end
end
- def count
- list_count
- end
-
- def count_by_story
- list_count
- end
-
- def count_by_author
- list_count
- end
-
def new
form_new
end
def create
set_model
- @comic = @item
@item = @my_model_class.new
@item.supply_default
- @item.attributes = params[@my_model_class.item_name]
+ @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+ @item.attributes = @item.permit_params params
@item.overwrite @operators
render_create
end
def update
set_edit
- @comic = @item
- @item.attributes = params[@my_model_class.item_name]
+ @my_model_class.fold_extend_settings params[@my_model_class.item_name]
+ @item.attributes = @item.permit_params params
@item.overwrite @operators
render_update
end
def destroy
- @item = Comic.edit(params[:id], @operators)
- respond_to do |format|
- if @item.destroy_with_leafs
- flash[:notice] = I18n.t('flash.notice.destroyed', :model => Comic.model_name.human)
- format.html { redirect_to '/home/comics' }
- format.json { head :ok }
- else
- flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Comic.model_name.human)
- format.html { redirect_to @item }
- format.json { render json: @item.errors, status: :unprocessable_entity }
- end
- end
+ set_model
+ @item = @my_model_class.edit(params[:id], @operators)
+ render_destroy '/home/' + @item.path_name
end
+
end