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]
34 @item = Story.show(params[:id], @operators)
36 respond_to do |format|
39 @new_sheet_items = assist_items('sheet', 'private_list')
40 @new_sheet_filer = assist_filer 'sheet', @new_sheet_items
44 format.json { render json: @item.to_json(Story.show_json_opt) }
49 @item = Story.show(params[:id], @operators)
50 @page = StorySheet.page params[:page]
51 @sheet = StorySheet.play_sheet(@item, @operators, @page)
52 respond_to do |format|
54 @paginate = StorySheet.play_paginate(@item, @page)
56 @new_sheet_items = assist_items('sheet', 'private_list')
57 @new_sheet_filer = assist_filer 'sheet', @new_sheet_items
62 @story_sheets = SheetPanel.play_list @sheet, @author
63 render text: SheetPanel.list_as_json_text(@story_sheets, @author)
69 render :json => "callback(" + @story_sheets.to_json_list + ");"
93 respond_to do |format|
96 format.json { render json: @story.to_json(Story.show_json_opt) }
101 @story = Story.edit(params[:id], @operators)
102 respond_to do |format|
110 @story.supply_default
111 @story.attributes = params[:story]
113 @comic = Comic.edit(@story.comic_id, @operators) if @story.comic_id
115 respond_to do |format|
116 if @story.store @operators
117 flash[:notice] = I18n.t('flash.notice.created', :model => Story.model_name.human)
118 format.html { redirect_to play_story_path(@story, :page => @story.t.to_i + 1) }
119 format.json { render json: @story.to_json(Story.show_json_opt) }
121 flash[:notice] = I18n.t('flash.notice.not_created', :model => Story.model_name.human)
122 format.html { render action: "new" }
123 format.json { render json: @story.errors, status: :unprocessable_entity }
129 @story = Story.edit(params[:id], @operators)
131 @story.attributes = params[:story]
133 respond_to do |format|
134 if @story.store @operators, ot
135 flash[:notice] = I18n.t('flash.notice.updated', :model => Story.model_name.human)
136 format.html { redirect_to play_story_path(@story, :page => @story.t.to_i + 1) }
137 format.json { head :ok }
139 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Story.model_name.human)
140 format.html { render action: "edit" }
141 format.json { render json: @story.errors, status: :unprocessable_entity }
147 @story = Story.edit(params[:id], @operators)
148 respond_to do |format|
149 if @story.destroy_and_shorten
150 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
151 format.html { redirect_to comic_path(@story.comic)}
152 format.json { head :ok }
154 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
155 format.html { redirect_to story_path(@story) }
156 format.json { render json: @story.errors, status: :unprocessable_entity }