X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fground_pictures_controller.rb;h=7d5fb1c9f55aa1fbd095fdfd6df0f71a4ddc522a;hb=69b61b39006c1951fc8c08746e884e63e50233b3;hp=cfc5392e10234dd21991a556bf566c9885e4a39d;hpb=2bb028878ce65185df4dd26927d7849635707c3b;p=pettanr%2Fpettanr.git diff --git a/app/controllers/ground_pictures_controller.rb b/app/controllers/ground_pictures_controller.rb index cfc5392e..7d5fb1c9 100644 --- a/app/controllers/ground_pictures_controller.rb +++ b/app/controllers/ground_pictures_controller.rb @@ -1,109 +1,56 @@ 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, :count, :count_by_panel, :count_by_author + ] + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end - + + def self.model + GroundPicture + end + def index - @page = GroundPicture.page params[:page] - @page_size = GroundPicture.page_size params[:page_size] - @ground_pictures = GroundPicture.list(@page, @page_size) - - respond_to do |format| - format.html # index.html.erb - format.json { render :json => @ground_pictures.to_json(GroundPicture.list_json_opt) } - end + filer_list end - - def show - @ground_picture = GroundPicture.show(params[:id], [@user, @admin]) - respond_to do |format| - format.html # show.html.erb - format.json { render json: @ground_picture.to_json(GroundPicture.show_json_opt) } - end + + def by_panel + filer_list end - def new - @ground_picture = GroundPicture.new params[:ground_picture] - @ground_picture.supply_default - @panel = @ground_picture.panel - - respond_to do |format| - format.html - format.json { render :json => @ground_picture.to_json(GroundPicture.show_json_opt) } - end + def by_author + filer_list 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 show_html_format format + format.html { + @ground_picture = @item + } end - - def create - @ground_picture = GroundPicture.new params[:ground_picture] - @ground_picture.supply_default - @ground_picture.overwrite - @panel = Panel.edit(@ground_picture.panel.id, @author) - + + def show + set_show 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 - format.html { render action: "panels/new" } - format.json { render json: @panel.errors, status: :unprocessable_entity } - end - else - format.html { render action: "new" } - 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 - - def update - @ground_picture = GroundPicture.show(params[:id], @author) - @ground_picture.attributes = params[:ground_picture] - @ground_picture.overwrite - @panel = Panel.edit(@ground_picture.panel.id, @author) - - 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 - format.html { render action: "edit" } - format.json { render json: @ground_picture.errors, status: :unprocessable_entity } - end - end + + def count + list_count end - - def destroy - @ground_picture = GroundPicture.show(params[:id], @author) - @panel = Panel.edit(@ground_picture.panel.id, @author) - - 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 - end + + def count_by_panel + list_count + end + + def count_by_author + list_count end end