1 class ScrollPanelsController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
4 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
6 before_filter :authenticate_reader, :only => [
7 :index, :show, :by_panel, :by_scroll, :count, :count_by_panel, :count_by_scroll
9 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
30 @item = ScrollPanel.show(params[:id], @operators)
32 respond_to do |format|
34 format.json { render json: @item.scroll_panel_as_json(@operators.author) }
51 @scroll_panel = ScrollPanel.new
52 @scroll_panel.supply_default
53 respond_to do |format|
56 format.json { render json: @scroll_panel.scroll_panel_as_json(@operators.author) }
61 @scroll_panel = ScrollPanel.edit(params[:id], @operators)
62 respond_to do |format|
69 @scroll_panel = ScrollPanel.new
70 @scroll_panel.supply_default
71 @scroll_panel.attributes = params[:scroll_panel]
72 @scroll_panel.overwrite @operators
73 @scroll = Scroll.edit(@scroll_panel.scroll_id, @operators) if @scroll_panel.scroll_id
74 @panel = Panel.show(@scroll_panel.panel_id, @operators) if @scroll_panel.panel_id
76 respond_to do |format|
77 if @scroll_panel.store @operators
78 flash[:notice] = I18n.t('flash.notice.created', :model => ScrollPanel.model_name.human)
79 format.html { redirect_to play_scroll_path(@scroll) }
80 format.json { render json: @scroll_panel.scroll_panel_as_json(@operators.author) }
82 flash[:notice] = I18n.t('flash.notice.not_created', :model => ScrollPanel.model_name.human)
83 format.html { render action: "new" }
84 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }
90 @scroll_panel = ScrollPanel.edit(params[:id], @operators)
92 @scroll_panel.attributes = params[:scroll_panel]
93 @scroll_panel.overwrite @operators
94 @scroll = Scroll.edit(@scroll_panel.scroll_id, @operators) if @scroll_panel.scroll_id
95 respond_to do |format|
96 if @scroll_panel.store @operators, ot
97 flash[:notice] = I18n.t('flash.notice.updated', :model => ScrollPanel.model_name.human)
98 format.html { redirect_to play_scroll_path(@scroll) }
99 format.json { head :ok }
101 flash[:notice] = I18n.t('flash.notice.not_updated', :model => ScrollPanel.model_name.human)
102 format.html { render action: "edit" }
103 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }
109 @scroll_panel = ScrollPanel.edit(params[:id], @operators)
110 @scroll = Scroll.edit(@scroll_panel.scroll_id, @operators) if @scroll_panel.scroll_id
111 respond_to do |format|
112 if @scroll_panel.destroy_and_shorten
113 flash[:notice] = I18n.t('flash.notice.destroyed', :model => ScrollPanel.model_name.human)
114 format.html { redirect_to play_scroll_path(@scroll) }
115 format.json { head :ok }
117 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => ScrollPanel.model_name.human)
118 format.html { redirect_to scroll_panel_path(@scroll_panel) }
119 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }