X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fscroll_panels_controller.rb;h=17532a79cf59ada741b6ad7fb762a696c2e462b9;hb=091b085aa054691dfe37d6f55f699dcb80f63ee5;hp=5c61a55f291da2154d68de685d13c2cafbbc38a0;hpb=2aa1323f37c9fb76373328c25e251291aa9addac;p=pettanr%2Fpettanr.git diff --git a/app/controllers/scroll_panels_controller.rb b/app/controllers/scroll_panels_controller.rb index 5c61a55f..17532a79 100644 --- a/app/controllers/scroll_panels_controller.rb +++ b/app/controllers/scroll_panels_controller.rb @@ -3,94 +3,71 @@ class ScrollPanelsController < ApplicationController before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else - before_filter :authenticate_reader, :only => [:index, :show, :by_panel, :by_scroll] + before_filter :authenticate_reader, :only => [ + :index, :show, :by_panel, :by_scroll, :by_author + ] before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end - - def self.model - ScrollPanel - end def index - public_list + filer_list end def by_panel - filter_list + filer_list end def by_scroll - filter_list + filer_list + end + + def by_author + filer_list end def show - @item = ScrollPanel.show(params[:id], @operators) - + set_show respond_to do |format| - format_prof format - format.json { render json: @item.scroll_panel_as_json(@operators.author) } + show_prof_format format + format.json { render json: @item.to_json } end end def new - @scroll_panel = ScrollPanel.new - @scroll_panel.supply_default - respond_to do |format| - format.html - format.js - format.json { render json: @scroll_panel.scroll_panel_as_json(@operators.author) } - end + form_new end - + def edit - @scroll_panel = ScrollPanel.edit(params[:id], @operators) - respond_to do |format| - format.html - format.js - end + form_edit end - + def create - @scroll_panel = ScrollPanel.new - @scroll_panel.supply_default - @scroll_panel.attributes = params[:scroll_panel] - @scroll_panel.overwrite @operators - @scroll = Scroll.edit(@scroll_panel.scroll_id, @operators) if @scroll_panel.scroll_id - @panel = Panel.show(@scroll_panel.panel_id, @operators) if @scroll_panel.panel_id + set_model + @item = @my_model_class.new + @item.supply_default + @item.attributes = params[@item.item_name] + @item.overwrite @operators + @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id + @panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id - respond_to do |format| - if @scroll_panel.store @operators - flash[:notice] = I18n.t('flash.notice.created', :model => ScrollPanel.model_name.human) - format.html { redirect_to play_scroll_path(@scroll) } - format.json { render json: @scroll_panel.scroll_panel_as_json(@operators.author) } - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => ScrollPanel.model_name.human) - format.html { render action: "new" } - format.json { render json: @scroll_panel.errors, status: :unprocessable_entity } - end - end + leaf_render_create play_scroll_path(@binder) end def update - @scroll_panel = ScrollPanel.edit(params[:id], @operators) - ot = @scroll_panel.t - @scroll_panel.attributes = params[:scroll_panel] - @scroll_panel.overwrite @operators - @scroll = Scroll.edit(@scroll_panel.scroll_id, @operators) if @scroll_panel.scroll_id - respond_to do |format| - if @scroll_panel.store @operators, ot - flash[:notice] = I18n.t('flash.notice.updated', :model => ScrollPanel.model_name.human) - format.html { redirect_to play_scroll_path(@scroll) } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => ScrollPanel.model_name.human) - format.html { render action: "edit" } - format.json { render json: @scroll_panel.errors, status: :unprocessable_entity } - end - end + set_model + @item = @my_model_class.edit(params[:id], @operators) + ot = @item.t + @item.attributes = params[@item.item_name] + @item.overwrite @operators + @binder = @my_model_class.binder_model.edit(@item.binder_id, @operators) if @item.binder_id + # no check permission for destination + # swapable hidden panel + #@panel = @my_model_class.destination_model.show(@item.destination_id, @operators) if @item.destination_id + + leaf_render_update ot, play_scroll_path(@binder) end - + def destroy @scroll_panel = ScrollPanel.edit(params[:id], @operators) @scroll = Scroll.edit(@scroll_panel.scroll_id, @operators) if @scroll_panel.scroll_id