X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fauthors_controller.rb;h=2b01c915f1c161f659c21a4769a6c46769da97c8;hb=674d4fb2e72c2e1653b13d026af884559fd9eb4e;hp=6f787a36db8a958cd5445f7921f821c7c45f9506;hpb=6871c7b0c1a7a02d4fe3b8ff597f3978e4df7f89;p=pettanr%2Fpettanr.git diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index 6f787a36..2b01c915 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -1,102 +1,59 @@ 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] 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], @author) - - respond_to do |format| - format.html - format.json { render :json => @au.to_json(Author.show_json_opt) } - end - end - - def count - @au = {:count => Author.visible_count} - respond_to do |format| - format.json { render json: @au.to_json } - end + filer_list end - def list - @authors = Author.all - - respond_to do |format| - format.html { render layout: 'system' } - end + def show_html_format format + format.html { + } end - - def browse - @au = Author.find(params[:id]) - + + def show + set_show respond_to do |format| - format.html { render layout: 'system' } + show_html_format format + show_prof_format format + show_json_format format end 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 - respond_to do |format| - if @au.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 } - else - format.html { render action: "new" } - format.json { render json: @au.errors, status: :unprocessable_entity } - end - end + set_model + @item = @my_model_class.new + @item.supply_default + @item.attributes = params[@my_model_class.item_name] + @item.overwrite @operators + render_create root_path end - + def update - @au = Author.edit(params[:id], @author) - @au.attributes = params[:author] - @au.overwrite @user.id - - respond_to do |format| - if @au.save - flash[:notice] = I18n.t('flash.notice.updated', :model => Author.model_name.human) - format.html { redirect_to '/home/configure' } - format.json { head :ok } - else - format.html { render action: "edit" } - format.json { render json: @au.errors, status: :unprocessable_entity } - end - end + set_edit + @item.attributes = params[@my_model_class.item_name] + @item.overwrite @operators + render_update '/home/configure' + end + + def destroy + set_model + @item = @my_model_class.edit(params[:id], @operators) + render_destroy '/home/configure' end + end