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]
29 def show_html_format format
31 play_list = Locmare::ListGroup.list(
32 'story_sheets', 'by_story', @operators,
33 {:id => @item.id, :my_play => @item.own?(@operators)}
35 @play_count = play_list.count(@operators)
41 respond_to do |format|
42 show_html_format format
43 show_prof_format format
44 show_json_format format
52 params[:page_size] = 1
54 @list = Locmare::ListGroup.list(
56 @my_action.name, @operators,
57 {:id => @item.id, :offset => 0, :limit => -1}# no limit
59 @items = @list.items(@operators)
60 @count = @list.count @operators
61 respond_to do |format|
63 if @item.own? @operators
64 @new_sheet_items = assist_items('home', 'sheets')
67 format.json { render json: @items.to_json }
98 @item = @my_model_class.new
100 @item.attributes = params[@my_model_class.item_name]
101 @item.overwrite @operators
108 @item.attributes = params[@my_model_class.item_name]
109 @item.overwrite @operators
114 @item = Story.edit(params[:id], @operators)
115 respond_to do |format|
116 if @item.destroy_with_leafs
117 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Story.model_name.human)
118 format.html { redirect_to '/home/stories' }
119 format.json { head :ok }
121 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Story.model_name.human)
122 format.html { redirect_to @item }
123 format.json { render json: @item.errors, status: :unprocessable_entity }