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,
37 {:id => @item.id, :my_play => @item.own?(@operators)}
44 respond_to do |format|
45 show_html_format format
46 show_prof_format format
47 show_json_format format
55 params[:page_size] = 1
56 @item = self.class.model.show(params[:id], @operators)
60 @sort_items = @list.items(@operators,
61 {:id => params[:id], :my_play => @item.own?(@operators)},
64 respond_to do |format|
66 if @item.own? @operators
67 @new_sheet_items = assist_items('sheet', 'private')
70 format.json { render json: @items.to_json }
101 @item = @my_model_class.new
103 @item.attributes = params[@my_model_class.item_name]
104 @item.overwrite @operators
111 @item.attributes = params[@my_model_class.item_name]
112 @item.overwrite @operators
117 @item = Story.edit(params[:id], @operators)
118 respond_to do |format|
119 if @item.destroy_with_leafs
120 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
121 format.html { redirect_to '/home/stories' }
122 format.json { head :ok }
124 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
125 format.html { redirect_to @item }
126 format.json { render json: @item.errors, status: :unprocessable_entity }