X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fauthors_controller.rb;h=2b01c915f1c161f659c21a4769a6c46769da97c8;hb=674d4fb2e72c2e1653b13d026af884559fd9eb4e;hp=9be51391359b27dcffa41cb689e18dabbe5e1586;hpb=8384758b15732ded84692b005ac44d9386026535;p=pettanr%2Fpettanr.git diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index 9be51391..2b01c915 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -1,137 +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, :scrolls, :scroll_panels, :comics, :stories, :story_sheets, :sheets, :sheet_panels, :panels, :panel_pictures, :speech_balloons, :ground_pictures, :ground_colors] + before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [:new, :create, :edit, :update] before_filter :authenticate_author, :only => [:edit, :update] end - def self.model - Author - end - def index - public_list - end - - def scrolls - has_many_list - end - - def scroll_panels - has_many_list - end - - def comics - has_many_list - end - - def stories - has_many_list - end - - def story_sheets - has_many_list - end - - def sheets - has_many_list - end - - def sheet_panels - has_many_list - end - - def panels - has_many_list - end - - def panel_pictures - has_many_list - end - - def speech_balloons - has_many_list - end - - def ground_pictures - has_many_list + filer_list end - def ground_colors - has_many_list + def show_html_format format + format.html { + } end def show - @item = Author.show(params[:id], @operators) - - respond_to do |format| - format.html { - @author = @item - } - format_prof format - format.json { render :json => @item.to_json(Author.show_json_opt) } - end - end - - def count - @au = {:count => Author.visible_count} + 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 new - @author = Author.new - @author.supply_default - - respond_to do |format| - format.html - format.js - format.json { render json: @au.to_json(Author.show_json_opt) } - end + form_new end - + def edit - @author = Author.edit(params[:id], @operators) + form_edit end - + def create - @author = Author.new() - @author.supply_default - @author.attributes = params[:author] - @author.overwrite @operators - respond_to do |format| - 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 + 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 - @author = Author.edit(params[:id], @operators) - @author.attributes = params[:author] - @author.overwrite @operators - - respond_to do |format| - 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 + 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