1 class ScrollPanelsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
5 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
7 before_filter :authenticate_reader, :only => [:index, :show, :scroll]
8 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
9 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
11 before_filter :authenticate_admin!, :only => [:list, :browse]
22 @item = ScrollPanel.show(params[:id], @operators)
24 respond_to do |format|
29 format.json { render json: @item.scroll_panel_as_json(@operators.author) }
34 @scroll_panels = ScrollPanel.all
36 respond_to do |format|
37 format.html { render layout: 'system' }# index.html.erb
38 format.json { render json: @scroll_panels }
43 @scroll_panel = ScrollPanel.find(params[:id])
45 respond_to do |format|
46 format.html { render layout: 'system' } # show.html.erb
47 format.json { render json: @scroll_panel }
52 @scroll_panel = ScrollPanel.new
53 @scroll_panel.supply_default
54 respond_to do |format|
55 format.html # new.html.erb
57 format.json { render json: @scroll_panel.scroll_panel_as_json(@author) }
62 @scroll_panel = ScrollPanel.edit(params[:id], @author)
63 respond_to do |format|
70 @scroll_panel = ScrollPanel.new
71 @scroll_panel.supply_default
72 @scroll_panel.attributes = params[:scroll_panel]
73 @scroll_panel.overwrite @author
74 @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
75 @panel = Panel.show(@scroll_panel.panel_id, @author) if @scroll_panel.panel_id
77 respond_to do |format|
78 if @scroll_panel.store
79 flash[:notice] = I18n.t('flash.notice.created', :model => ScrollPanel.model_name.human)
80 format.html { redirect_to play_scroll_path(@scroll) }
81 format.json { render json: @scroll_panel.scroll_panel_as_json(@author) }
83 flash[:notice] = I18n.t('flash.notice.not_created', :model => ScrollPanel.model_name.human)
84 format.html { render action: "new" }
85 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }
91 @scroll_panel = ScrollPanel.edit(params[:id], @author)
93 @scroll_panel.attributes = params[:scroll_panel]
94 @scroll_panel.overwrite @author
95 @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
96 respond_to do |format|
97 if @scroll_panel.store ot
98 flash[:notice] = I18n.t('flash.notice.updated', :model => ScrollPanel.model_name.human)
99 format.html { redirect_to play_scroll_path(@scroll) }
100 format.json { head :ok }
102 flash[:notice] = I18n.t('flash.notice.not_updated', :model => ScrollPanel.model_name.human)
103 format.html { render action: "edit" }
104 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }
110 @scroll_panel = ScrollPanel.edit(params[:id], @author)
111 @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
112 respond_to do |format|
113 if @scroll_panel.destroy_and_shorten
114 flash[:notice] = I18n.t('flash.notice.destroyed', :model => ScrollPanel.model_name.human)
115 format.html { redirect_to play_scroll_path(@scroll) }
116 format.json { head :ok }
118 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => ScrollPanel.model_name.human)
119 format.html { redirect_to scroll_panel_path(@scroll_panel) }
120 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }