1 class StoriesController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
4 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
6 before_filter :authenticate_reader, :only => [
7 :index, :show, :play, :by_comic, :by_sheet, :by_author, :count, :count_by_comic, :count_by_sheet, :count_by_author
9 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
33 def show_html_format format
35 play_list = Locmare::ListGroup.list 'story_sheet', 'play'
36 @play_count = play_list.count(@operators, {:id => @item.id, :my_play => @item.own?(@operators)})
38 @new_comic_items = assist_items('comic', 'private')
45 respond_to do |format|
46 show_html_format format
47 show_prof_format format
48 show_json_format format
53 @item = self.class.model.show(params[:id], @operators)
56 @options = {:id => params[:id], :offset => params[:offset], :count => 1}
57 list_result = @list.open(@operators, @options)
58 @items = list_result.items
59 @count = @list.count(@operators, @options)
60 @pager = Kaminari.paginate_array(Array.new(@count, nil)).page(params[:offset]).per(1)
61 @sort_items = @list.items(@operators,
62 {:id => params[:id], :my_play => @item.own?(@operators)},
65 respond_to do |format|
67 #@count = @action.list.count @item
68 #@prev_offset = @action.list.prev_offset @item
69 #@next_offset = @action.list.next_offset @item
71 @new_sheet_items = assist_items('sheet', 'private')
74 format.json { render json: @items.to_json(self.class.model.list_json_opt) }
105 @item = @my_model_class.new
107 @item.attributes = params[@my_model_class.item_name]
108 @item.overwrite @operators
115 @item.attributes = params[@my_model_class.item_name]
116 @item.overwrite @operators
121 @item = Story.edit(params[:id], @operators)
122 respond_to do |format|
123 if @item.destroy_with_leafs
124 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
125 format.html { redirect_to '/home/stories' }
126 format.json { head :ok }
128 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
129 format.html { redirect_to @item }
130 format.json { render json: @item.errors, status: :unprocessable_entity }