X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fpanel_pictures_controller.rb;h=3ae4dac9c218eb26b4f58116b1a71c659d89f00e;hb=d6d237012089604cdbc61943856d42c0a0472dc7;hp=728215c0941bb73c9518a7b7fb49565f596e3406;hpb=4d24ee5624fe3cf7126e9c07d450b93766c8f6c3;p=pettanr%2Fpettanr.git diff --git a/app/controllers/panel_pictures_controller.rb b/app/controllers/panel_pictures_controller.rb index 728215c0..3ae4dac9 100644 --- a/app/controllers/panel_pictures_controller.rb +++ b/app/controllers/panel_pictures_controller.rb @@ -1,17 +1,13 @@ class PanelPicturesController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [ - :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author + :index, :show, :by_panel, :by_author ] - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] - end - - def self.model - PanelPicture + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end def index @@ -40,117 +36,5 @@ class PanelPicturesController < ApplicationController show_json_format format end end - - def count - list_count - end - - def count_by_panel - list_count - end - - def count_by_author - list_count - end - - def new - raise Pettanr::NotWork unless @operators.author.working_panel - @picture = Picture.show params[:picture_id], @operators - raise ActiveRecord::Forbidden unless @picture.enable? - @panel = Panel.edit(@operators.author.working_panel, @operators) - - @item = PanelPicture.new :panel_id => @panel.id, :picture_id => @picture.id - @item.supply_default - respond_to do |format| - format.html { - mounted = 1 - form_manager = Pettanr::Application::manifest.form_managers[@item.form_name] - @form = form_manager.open @item, @operators, mounted - } - format.json { render :json => @panel_picture.to_json(PanelPicture.show_json_opt) } - end - end - - def edit - @item = PanelPicture.show(params[:id], @operators) - @panel = Panel.edit(@item.panel.id, @operators) - - respond_to do |format| - format.html { - mounted = 1 - form_manager = Pettanr::Application::manifest.form_managers[@item.form_name] - @form = form_manager.open @item, @operators, mounted - } - end - end - - def create - raise Pettanr::NotWork unless @operators.author.working_panel - @panel = Panel.edit(@operators.author.working_panel, @operators) - - @panel_picture = PanelPicture.new - @panel_picture.attributes = params[:panel_picture] - @panel_picture.overwrite @panel.id - - @picture = Picture.show @panel_picture.picture_id, @operators - raise ActiveRecord::Forbidden unless @picture.enable? - - respond_to do |format| - if @panel_picture.valid? - if @panel_picture.store @operators - 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 => PanelPicture.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 => PanelPicture.model_name.human) - format.html { render action: "new" } - format.json { render json: @panel_picture.errors, status: :unprocessable_entity } - end - end - end - - def update - @panel_picture = PanelPicture.show(params[:id], @operators) - @panel_picture.attributes = params[:panel_picture] - @panel = Panel.edit(@panel_picture.panel.id, @operators) - @panel_picture.overwrite @panel.id - - @picture = Picture.show @panel_picture.picture_id, @operators - raise ActiveRecord::Forbidden unless @picture.enable? - - respond_to do |format| - if @panel_picture.store @operators - flash[:notice] = I18n.t('flash.notice.updated', :model => PanelPicture.model_name.human) - format.html { redirect_to @panel_picture } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => PanelPicture.model_name.human) - format.html { render action: "edit" } - format.json { render json: @panel_picture.errors, status: :unprocessable_entity } - end - end - end - - def destroy - @panel_picture = PanelPicture.show(params[:id], @operators) - @panel = Panel.edit(@panel_picture.panel.id, @operators) - - respond_to do |format| - if @panel_picture.remove @operators - flash[:notice] = I18n.t('flash.notice.destroyed', :model => PanelPicture.model_name.human) - format.html { redirect_to @panel } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => PanelPicture.model_name.human) - format.html { redirect_to @panel_picture } - format.json { render json: @panel_picture.errors, status: :unprocessable_entity } - end - end - end end