1 class AuthorsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
5 before_filter :authenticate_author, :only => [:edit, :update]
7 before_filter :authenticate_reader, :only => [:index, :show, :scrolls, :scroll_panels, :comics, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors]
8 before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
9 before_filter :authenticate_author, :only => [:edit, :update]
69 @item = Author.show(params[:id], @operators)
71 respond_to do |format|
76 format.json { render :json => @item.to_json(Author.show_json_opt) }
81 @au = {:count => Author.visible_count}
82 respond_to do |format|
83 format.json { render json: @au.to_json }
89 @author.supply_default
91 respond_to do |format|
94 format.json { render json: @au.to_json(Author.show_json_opt) }
99 @author = Author.edit(params[:id], @operators)
103 @author = Author.new()
104 @author.supply_default
105 @author.attributes = params[:author]
106 @author.overwrite @operators
107 respond_to do |format|
109 flash[:notice] = I18n.t('flash.notice.created', :model => Author.model_name.human)
110 format.html { redirect_to root_path }
111 format.json { render json: @author.to_json(Author.show_json_opt), status: :created }
113 flash[:notice] = I18n.t('flash.notice.not_created', :model => Author.model_name.human)
114 format.html { render action: "new" }
115 format.json { render json: @au.errors, status: :unprocessable_entity }
121 @author = Author.edit(params[:id], @operators)
122 @author.attributes = params[:author]
123 @author.overwrite @operators
125 respond_to do |format|
127 flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human)
128 format.html { redirect_to '/home/configure' }
129 format.json { head :ok }
131 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Author.model_name.human)
132 format.html { render action: "edit" }
133 format.json { render json: @author.errors, status: :unprocessable_entity }