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]
14 @page = ScrollPanel.page params[:page]
15 @page_size = ScrollPanel.page_size params[:page_size]
16 @scroll_panels = ScrollPanel.list(@page, @page_size)
18 respond_to do |format|
20 @paginate = ScrollPanel.list_paginate(@page, @page_size)
22 format.json { render :json => @scroll_panels.to_json(ScrollPanel.list_json_opt) }
27 @scroll_panel = ScrollPanel.show(params[:id], [@user, @admin])
29 respond_to do |format|
30 format.html # show.html.erb
31 format.prof { render :template => 'top/prof', :layout => true }
32 format.json { render json: @scroll_panel.scroll_panel_as_json(@author) }
37 @scroll_panels = ScrollPanel.all
39 respond_to do |format|
40 format.html { render layout: 'system' }# index.html.erb
41 format.json { render json: @scroll_panels }
46 @scroll_panel = ScrollPanel.find(params[:id])
48 respond_to do |format|
49 format.html { render layout: 'system' } # show.html.erb
50 format.json { render json: @scroll_panel }
55 @scroll_panel = ScrollPanel.new
56 @scroll_panel.supply_default
57 respond_to do |format|
58 format.html # new.html.erb
60 format.json { render json: @scroll_panel.scroll_panel_as_json(@author) }
65 @scroll_panel = ScrollPanel.edit(params[:id], @author)
66 respond_to do |format|
73 @scroll_panel = ScrollPanel.new
74 @scroll_panel.supply_default
75 @scroll_panel.attributes = params[:scroll_panel]
76 @scroll_panel.overwrite @author
77 @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
78 @panel = Panel.show(@scroll_panel.panel_id, @author) if @scroll_panel.panel_id
80 respond_to do |format|
81 if @scroll_panel.store
82 flash[:notice] = I18n.t('flash.notice.created', :model => ScrollPanel.model_name.human)
83 format.html { redirect_to play_scroll_path(@scroll) }
84 format.json { render json: @scroll_panel.scroll_panel_as_json(@author) }
86 flash[:notice] = I18n.t('flash.notice.not_created', :model => ScrollPanel.model_name.human)
87 format.html { render action: "new" }
88 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }
94 @scroll_panel = ScrollPanel.edit(params[:id], @author)
96 @scroll_panel.attributes = params[:scroll_panel]
97 @scroll_panel.overwrite @author
98 @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
99 respond_to do |format|
100 if @scroll_panel.store ot
101 flash[:notice] = I18n.t('flash.notice.updated', :model => ScrollPanel.model_name.human)
102 format.html { redirect_to play_scroll_path(@scroll) }
103 format.json { head :ok }
105 flash[:notice] = I18n.t('flash.notice.not_updated', :model => ScrollPanel.model_name.human)
106 format.html { render action: "edit" }
107 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }
113 @scroll_panel = ScrollPanel.edit(params[:id], @author)
114 @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
115 respond_to do |format|
116 if @scroll_panel.destroy_and_shorten
117 flash[:notice] = I18n.t('flash.notice.destroyed', :model => ScrollPanel.model_name.human)
118 format.html { redirect_to play_scroll_path(@scroll) }
119 format.json { head :ok }
121 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => ScrollPanel.model_name.human)
122 format.html { redirect_to scroll_panel_path(@scroll_panel) }
123 format.json { render json: @scroll_panel.errors, status: :unprocessable_entity }