1 class AuthorsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update]
4 before_filter :authenticate_author, :only => [:index, :show, :edit, :update]
5 before_filter :authenticate_admin!, :only => [:list, :browse]
8 @page = Author.page params[:page]
9 @page_size = Author.page_size params[:page_size]
10 @authors = Author.list(@page, @page_size)
12 respond_to do |format|
13 format.html # index.html.erb
14 format.json { render :json => @authors.to_json(Author.list_json_opt) }
19 @au = Author.show(params[:id], @author)
21 respond_to do |format|
23 format.json { render :json => @au.to_json(Author.show_json_opt) }
28 @au = {:count => Author.visible_count}
29 respond_to do |format|
30 format.json { render json: @au.to_json }
37 respond_to do |format|
38 format.html { render layout: 'system' }
43 @au = Author.find(params[:id])
45 respond_to do |format|
46 format.html { render layout: 'system' }
54 respond_to do |format|
55 format.html # new.html.erb
57 format.json { render json: @au.to_json(Author.show_json_opt) }
62 @au = Author.edit(params[:id], @author)
68 @au.attributes = params[:author]
69 @au.overwrite @user.id
70 respond_to do |format|
72 format.html { redirect_to @au, notice: 'Author was successfully created.' }
73 format.json { render json: @au.to_json(Author.show_json_opt), status: :created, location: @artist }
75 format.html { render action: "new" }
76 format.json { render json: @au.errors, status: :unprocessable_entity }
82 @au = Author.edit(params[:id], @author)
83 @au.attributes = params[:author]
84 @au.overwrite @user.id
86 respond_to do |format|
88 format.html { redirect_to @au, notice: 'Author was successfully updated.' }
89 format.json { head :ok }
91 format.html { render action: "edit" }
92 format.json { render json: @au.errors, status: :unprocessable_entity }