class AuthorsController < ApplicationController
- layout 'test' if MagicNumber['test_layout']
- if MagicNumber['run_mode'] == 0
+ 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, :comics, :stories, :panels]
+ 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
- before_filter :authenticate_admin!, :only => [:list, :browse]
- def index
- @page = Author.page params[:page]
- @page_size = Author.page_size params[:page_size]
- @authors = Author.list(@page, @page_size)
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render :json => @authors.to_json(Author.list_json_opt) }
- end
- end
-
- def show
- @au = Author.show(params[:id], [@user, @admin])
-
- respond_to do |format|
- format.html
- format.json { render :json => @au.to_json(Author.show_json_opt) }
- end
- end
-
- def comics
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.comic_page_size params[:page_size]
- @comics = Comic.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @comics.to_json(Comic.list_json_opt) }
- end
+ def self.model
+ Author
end
- def stories
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.comic_page_size params[:page_size]
- @stories = Story.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @stories.to_json(Story.list_json_opt) }
- end
+ def index
+ filer_list
end
- def panels
- @au = Author.show(params[:id], [@user, @admin])
-
- @page = Author.page params[:page]
- @page_size = Author.panel_page_size params[:page_size]
- @panels = Panel.himlist(@au, @page, @page_size)
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render text: Panel.list_as_json_text(@panels) }
- end
+ def show_html_format format
+ format.html {
+ @author = @item
+ }
end
- def count
- @au = {:count => Author.visible_count}
+ def show
+ set_show
respond_to do |format|
- format.json { render json: @au.to_json }
+ show_html_format format
+ show_prof_format format
+ show_json_format format
end
end
- def list
- @authors = Author.all
-
- respond_to do |format|
- format.html { render layout: 'system' }
- end
- end
-
- def browse
- @au = Author.find(params[:id])
-
- respond_to do |format|
- format.html { render layout: 'system' }
- end
+ def count
+ list_count
end
def new
- @au = Author.new
- @au.supply_default
-
- respond_to do |format|
- format.html # new.html.erb
- format.js
- format.json { render json: @au.to_json(Author.show_json_opt) }
- end
+ form_new
end
-
+
def edit
- @au = Author.edit(params[:id], @author)
+ form_edit
end
-
+
def create
- @au = Author.new()
- @au.supply_default
- @au.attributes = params[:author]
- @au.overwrite @user.id
+ @author = Author.new()
+ @author.supply_default
+ @author.attributes = params[:author]
+ @author.overwrite @operators
respond_to do |format|
- if @au.save
+ 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: @au.to_json(Author.show_json_opt), status: :created, location: @artist }
+ 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
def update
- @au = Author.edit(params[:id], @author)
- @au.attributes = params[:author]
- @au.overwrite @user.id
+ @author = Author.edit(params[:id], @operators)
+ @author.attributes = params[:author]
+ @author.overwrite @operators
respond_to do |format|
- if @au.save
+ 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: @au.errors, status: :unprocessable_entity }
+ format.json { render json: @author.errors, status: :unprocessable_entity }
end
end
end