1 class AuthorsController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
4 before_filter :authenticate_author, :only => [:edit, :update]
6 before_filter :authenticate_reader, :only => [:index, :show, :count]
7 before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
8 before_filter :authenticate_author, :only => [:edit, :update]
20 @item = Author.show(params[:id], @operators)
22 respond_to do |format|
27 format.json { render :json => @item.to_json(Author.show_json_opt) }
37 @author.supply_default
39 respond_to do |format|
42 format.json { render json: @au.to_json(Author.show_json_opt) }
47 @author = Author.edit(params[:id], @operators)
51 @author = Author.new()
52 @author.supply_default
53 @author.attributes = params[:author]
54 @author.overwrite @operators
55 respond_to do |format|
57 flash[:notice] = I18n.t('flash.notice.created', :model => Author.model_name.human)
58 format.html { redirect_to root_path }
59 format.json { render json: @author.to_json(Author.show_json_opt), status: :created }
61 flash[:notice] = I18n.t('flash.notice.not_created', :model => Author.model_name.human)
62 format.html { render action: "new" }
63 format.json { render json: @au.errors, status: :unprocessable_entity }
69 @author = Author.edit(params[:id], @operators)
70 @author.attributes = params[:author]
71 @author.overwrite @operators
73 respond_to do |format|
75 flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human)
76 format.html { redirect_to '/home/configure' }
77 format.json { head :ok }
79 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Author.model_name.human)
80 format.html { render action: "edit" }
81 format.json { render json: @author.errors, status: :unprocessable_entity }