X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fground_colors_controller.rb;h=c9be0d39948e2c3a55291a7538b6258ec5fc38d6;hb=2788400e911d92496bf76bbae44021353b287ba0;hp=f990f241f1c32684d03b3e84a172b877a615fb8c;hpb=10d7d403b74c06dcbf42a132b9712c3817547284;p=pettanr%2Fpettanr.git diff --git a/app/controllers/ground_colors_controller.rb b/app/controllers/ground_colors_controller.rb index f990f241..c9be0d39 100644 --- a/app/controllers/ground_colors_controller.rb +++ b/app/controllers/ground_colors_controller.rb @@ -1,117 +1,39 @@ class GroundColorsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + if Manifest.manifest.magic_numbers['run_mode'] == 0 + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] else - before_filter :authenticate_reader, :only => [:index, :show] - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_action :authenticate_reader, :only => [ + :index, :show, :by_panel, :by_author + ] + before_action :authenticate_user, :only => [] + before_action :authenticate_author, :only => [] end - + def index - @page = GroundColor.page params[:page] - @page_size = GroundColor.page_size params[:page_size] - @ground_colors = GroundColor.list(@page, @page_size) - - respond_to do |format| - format.html { - @paginate = GroundColor.list_paginate(@page, @page_size) - } - format.json { render :json => @ground_colors.to_json(GroundColor.list_json_opt) } - end + filer_list end - def show - @ground_color = GroundColor.show(params[:id], [@user, @admin]) - respond_to do |format| - format.html # show.html.erb - format.prof { render :template => 'top/prof', :layout => true } - format.json { render json: @ground_color.to_json(GroundColor.show_json_opt) } - end + def by_panel + filer_list param: params[:id] end - def new - raise Pettanr::NotWork unless @author.working_panel - @panel = Panel.edit(@author.working_panel, @author) - @ground_color = GroundColor.new :panel_id => @panel.id, :code => params[:code].to_i - @ground_color.supply_default - - respond_to do |format| - format.html - format.json { render :json => @ground_color.to_json(GroundColor.show_json_opt) } - end + def by_author + filer_list param: params[:id] end - - def edit - @ground_color = GroundColor.show(params[:id], @author) - @panel = Panel.edit(@ground_color.panel.id, @author) - - respond_to do |format| - format.html - end - end - - def create - raise Pettanr::NotWork unless @author.working_panel - @panel = Panel.edit(@author.working_panel, @author) - - @ground_color = GroundColor.new - @ground_color.attributes = params[:ground_color] - @ground_color.overwrite @panel.id - - respond_to do |format| - if @ground_color.valid? - if @ground_color.store @author - flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human) - format.html { redirect_to @panel } - format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel } - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human) - format.html { render action: "new" } - format.json { render json: @ground_color.errors, status: :unprocessable_entity } - end - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human) - format.html { render action: "new" } - format.json { render json: @ground_color.errors, status: :unprocessable_entity } - end - end - end - - def update - @ground_color = GroundColor.show(params[:id], @author) - @ground_color.attributes = params[:ground_color] - @panel = Panel.edit(@ground_color.panel.id, @author) - @ground_color.overwrite @panel.id - - respond_to do |format| - if @ground_color.store @author - flash[:notice] = I18n.t('flash.notice.updated', :model => GroundColor.model_name.human) - format.html { redirect_to @ground_color } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundColor.model_name.human) - format.html { render action: "edit" } - format.json { render json: @ground_color.errors, status: :unprocessable_entity } - end - end + + def show_html_format format + format.html { + @ground_color = @item + } end - - def destroy - @ground_color = GroundColor.show(params[:id], @author) - @panel = Panel.edit(@ground_color.panel.id, @author) - + + def show + set_show respond_to do |format| - if @ground_color.remove @author - flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundColor.model_name.human) - format.html { redirect_to @panel } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundColor.model_name.human) - format.html { redirect_to @ground_color } - format.json { render json: @ground_color.errors, status: :unprocessable_entity } - end + show_html_format format + show_prof_format format + show_json_format format end end