1 class ScrollsController < 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 => [:top, :index, :show, :play, :by_author, :by_panel]
7 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
8 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
28 @item = Scroll.show(params[:id], @operators)
30 respond_to do |format|
33 @new_panel_items = assist_items('panel', 'private_list')
34 @new_panel_filer = assist_filer 'panel', @new_panel_items
37 format.json { render json: @item.to_json(Scroll.show_json_opt) }
45 @item = self.class.model.show(params[:id], @operators)
46 action_name = params[:action]
47 @action = self.class.controller.open(action_name, params, @operators)
48 @items = @action.list.items @item
49 respond_to do |format|
51 @count = @action.list.count @item
52 @prev_offset = @action.list.prev_offset @item
53 @next_offset = @action.list.next_offset @item
55 @new_panel_items = assist_items('panel', 'private_list')
56 @new_panel_filer = assist_filer 'panel', @new_panel_items
59 format.json { render json: @items.to_json(self.class.model.list_json_opt) }
80 @scroll = Scroll.edit(params[:id], @operators)
81 respond_to do |format|
89 @scroll.supply_default
90 @scroll.attributes = params[:scroll]
91 @scroll.overwrite @operators
93 respond_to do |format|
95 flash[:notice] = I18n.t('flash.notice.created', :model => Scroll.model_name.human)
96 format.html { redirect_to @scroll }
97 format.json { render json: @scroll.to_json(Scroll.show_json_opt), status: :created, location: @scroll }
99 flash[:notice] = I18n.t('flash.notice.not_created', :model => Scroll.model_name.human)
100 format.html { render action: "new" }
101 format.json { render json: @scroll.errors, status: :unprocessable_entity }
107 @scroll = Scroll.edit(params[:id], @operators)
108 @scroll.attributes = params[:scroll]
109 @scroll.overwrite @operators
110 respond_to do |format|
112 flash[:notice] = I18n.t('flash.notice.updated', :model => Scroll.model_name.human)
113 format.html { redirect_to @scroll }
114 format.json { head :ok }
116 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Scroll.model_name.human)
117 format.html { render action: "edit" }
118 format.json { render json: @scroll.errors, status: :unprocessable_entity }
124 @scroll = Scroll.edit(params[:id], @operators)
125 respond_to do |format|
126 if @scroll.destroy_with_scroll_panel
127 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)
128 format.html { redirect_to '/home/scrolls' }
129 format.json { head :ok }
131 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Scroll.model_name.human)
132 format.html { redirect_to @scroll }
133 format.json { render json: @scroll.errors, status: :unprocessable_entity }