class AuthorsController < ApplicationController
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_admin!, :only => [:list, :browse]
+ if Manifest.manifest.magic_numbers['run_mode'] == 0
+ before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
+ before_filter :authenticate_author, :only => [:edit, :update]
+ else
+ before_filter :authenticate_reader, :only => [:index, :show, :count]
+ before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
+ before_filter :authenticate_author, :only => [:edit, :update]
+ end
+ def self.model
+ Author
+ end
+
def index
- @authors = Author.all
-
- respond_to do |format|
- format.html # index.html.erb
- end
+ filer_list
end
-
+
+ def show_html_format format
+ format.html {
+ @author = @item
+ }
+ end
+
def show
- @author = Author.find(params[:id])
-
+ set_show
respond_to do |format|
- format.html
+ show_html_format format
+ show_prof_format format
+ show_json_format format
end
end
-
- def list
- @authors = Author.all
-
+
+ def count
+ list_count
+ end
+
+ def new
+ form_new
+ end
+
+ def edit
+ form_edit
+ end
+
+ def create
+ @author = Author.new()
+ @author.supply_default
+ @author.attributes = params[:author]
+ @author.overwrite @operators
respond_to do |format|
- format.html { render layout: 'system' }
+ if @author.save
+ flash[:notice] = I18n.t('flash.notice.created', :model => Author.model_name.human)
+ format.html { redirect_to root_path }
+ format.json { render json: @author.to_json(Author.show_json_opt), status: :created }
+ else
+ flash[:notice] = I18n.t('flash.notice.not_created', :model => Author.model_name.human)
+ format.html { render action: "new" }
+ format.json { render json: @au.errors, status: :unprocessable_entity }
+ end
end
end
- def browse
- @author = Author.find(params[:id])
+ def update
+ @author = Author.edit(params[:id], @operators)
+ @author.attributes = params[:author]
+ @author.overwrite @operators
respond_to do |format|
- format.html { render layout: 'system' }
+ if @author.save
+ flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human)
+ format.html { redirect_to '/home/configure' }
+ format.json { head :ok }
+ else
+ flash[:notice] = I18n.t('flash.notice.not_updated', :model => Author.model_name.human)
+ format.html { render action: "edit" }
+ format.json { render json: @author.errors, status: :unprocessable_entity }
+ end
end
end
-
end