X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fground_pictures_controller.rb;h=db7c55348785fa9316799171c8817c793a1703be;hb=6733d61c6f0551647a023be3006cb70901497c36;hp=9de210712c2de8a3054dcc12562c01dd717e0cd7;hpb=ffcde0e88b1283f7cd05cfc2ed939de88cc8e7be;p=pettanr%2Fpettanr.git diff --git a/app/controllers/ground_pictures_controller.rb b/app/controllers/ground_pictures_controller.rb index 9de21071..db7c5534 100644 --- a/app/controllers/ground_pictures_controller.rb +++ b/app/controllers/ground_pictures_controller.rb @@ -1,125 +1,39 @@ class GroundPicturesController < 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_filter :authenticate_user, :only => [] + before_filter :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_filter :authenticate_reader, :only => [ + :index, :show, :by_panel, :by_author + ] + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end - - @@model = GroundPicture + def index - set_filer - - respond_to do |format| - format_filer format - format.json { render json: @items.to_json(@@model.list_json_opt) } - end - end - - def show - @item = GroundPicture.show(params[:id], @operators) - respond_to do |format| - format.html { - @ground_picture = @item - } - format_prof format - format.json { render json: @item.to_json(GroundPicture.show_json_opt) } - end + filer_list end - def new - raise Pettanr::NotWork unless @author.working_panel - @picture = Picture.show params[:picture_id], @author - raise ActiveRecord::Forbidden unless @picture.enable? - @panel = Panel.edit(@author.working_panel, @author) - - @ground_picture = GroundPicture.new :panel_id => @panel.id, :picture_id => @picture.id - @ground_picture.supply_default - - respond_to do |format| - format.html - format.json { render :json => @ground_picture.to_json(GroundPicture.show_json_opt) } - end - end - - def edit - @ground_picture = GroundPicture.show(params[:id], @author) - @panel = Panel.edit(@ground_picture.panel.id, @author) - - respond_to do |format| - format.html - end + def by_panel + filer_list end - - def create - raise Pettanr::NotWork unless @author.working_panel - @panel = Panel.edit(@author.working_panel, @author) - - @ground_picture = GroundPicture.new - @ground_picture.attributes = params[:ground_picture] - @ground_picture.overwrite @panel.id - - @picture = Picture.show @ground_picture.picture_id, @author - raise ActiveRecord::Forbidden unless @picture.enable? - - respond_to do |format| - if @ground_picture.valid? - if @ground_picture.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 => GroundPicture.model_name.human) - format.html { render action: "new" } - format.json { render json: @panel.errors, status: :unprocessable_entity } - end - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human) - format.html { render action: "new" } - format.json { render json: @ground_picture.errors, status: :unprocessable_entity } - end - end + + def by_author + filer_list end - - def update - @ground_picture = GroundPicture.show(params[:id], @author) - @ground_picture.attributes = params[:ground_picture] - @panel = Panel.edit(@ground_picture.panel.id, @author) - @ground_picture.overwrite @panel.id - - @picture = Picture.show @ground_picture.picture_id, @author - raise ActiveRecord::Forbidden unless @picture.enable? - - respond_to do |format| - if @ground_picture.store @author - flash[:notice] = I18n.t('flash.notice.updated', :model => GroundPicture.model_name.human) - format.html { redirect_to @ground_picture } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundPicture.model_name.human) - format.html { render action: "edit" } - format.json { render json: @ground_picture.errors, status: :unprocessable_entity } - end - end + + def show_html_format format + format.html { + @ground_picture = @item + } end - - def destroy - @ground_picture = GroundPicture.show(params[:id], @author) - @panel = Panel.edit(@ground_picture.panel.id, @author) - + + def show + set_show respond_to do |format| - if @ground_picture.remove @author - flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundPicture.model_name.human) - format.html { redirect_to @panel } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundPicture.model_name.human) - format.html { redirect_to @ground_picture } - format.json { render json: @ground_picture.errors, status: :unprocessable_entity } - end + show_html_format format + show_prof_format format + show_json_format format end end