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)
59 @sort_items = @list.items(@operators,
60 {:id => params[:id], :my_play => @item.own?(@operators)},
63 respond_to do |format|
65 if @item.own? @operators
66 @new_sheet_items = assist_items('sheet', 'private')
69 format.json { render json: @items.to_json }
100 @item = @my_model_class.new
102 @item.attributes = params[@my_model_class.item_name]
103 @item.overwrite @operators
110 @item.attributes = params[@my_model_class.item_name]
111 @item.overwrite @operators
116 @item = Story.edit(params[:id], @operators)
117 respond_to do |format|
118 if @item.destroy_with_leafs
119 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
120 format.html { redirect_to '/home/stories' }
121 format.json { head :ok }
123 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
124 format.html { redirect_to @item }
125 format.json { render json: @item.errors, status: :unprocessable_entity }