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]
6 before_filter :authenticate_reader, :only => [:index, :show]
7 before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
9 before_filter :authenticate_admin!, :only => [:list, :browse]
12 @page = Author.page params[:page]
13 @page_size = Author.page_size params[:page_size]
14 @authors = Author.list(@page, @page_size)
16 respond_to do |format|
17 format.html # index.html.erb
18 format.json { render :json => @authors.to_json(Author.list_json_opt) }
23 @au = Author.show(params[:id], [@author, @admin])
25 respond_to do |format|
27 format.json { render :json => @au.to_json(Author.show_json_opt) }
32 @au = {:count => Author.visible_count}
33 respond_to do |format|
34 format.json { render json: @au.to_json }
41 respond_to do |format|
42 format.html { render layout: 'system' }
47 @au = Author.find(params[:id])
49 respond_to do |format|
50 format.html { render layout: 'system' }
58 respond_to do |format|
59 format.html # new.html.erb
61 format.json { render json: @au.to_json(Author.show_json_opt) }
66 @au = Author.edit(params[:id], @author)
72 @au.attributes = params[:author]
73 @au.overwrite @user.id
74 respond_to do |format|
76 flash[:notice] = I18n.t('flash.notice.created', :model => Author.model_name.human)
77 format.html { redirect_to root_path }
78 format.json { render json: @au.to_json(Author.show_json_opt), status: :created, location: @artist }
80 format.html { render action: "new" }
81 format.json { render json: @au.errors, status: :unprocessable_entity }
87 @au = Author.edit(params[:id], @author)
88 @au.attributes = params[:author]
89 @au.overwrite @user.id
91 respond_to do |format|
93 flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human)
94 format.html { redirect_to '/home/configure' }
95 format.json { head :ok }
97 format.html { render action: "edit" }
98 format.json { render json: @au.errors, status: :unprocessable_entity }