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) }
86 @item.attributes = params[:scroll]
87 @item.overwrite @operators
90 respond_to do |format|
91 flash[:notice] = I18n.t('flash.notice.created', :model => Scroll.model_name.human)
92 format.html { redirect_to @item }
93 format.json { render json: @item.to_json(Scroll.show_json_opt), status: :created, location: @item }
96 flash[:notice] = I18n.t('flash.notice.not_created', :model => Scroll.model_name.human)
98 format.html { render action: "new" }
99 format.json { render json: @item.errors, status: :unprocessable_entity }
104 @item = Scroll.edit(params[:id], @operators)
105 @item.attributes = params[:scroll]
106 @item.overwrite @operators
107 respond_to do |format|
109 flash[:notice] = I18n.t('flash.notice.updated', :model => Scroll.model_name.human)
110 format.html { redirect_to @item }
111 format.json { head :ok }
113 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Scroll.model_name.human)
114 format.html { render action: "edit" }
115 format.json { render json: @item.errors, status: :unprocessable_entity }
121 @item = Scroll.edit(params[:id], @operators)
122 respond_to do |format|
123 if @item.destroy_with_scroll_panel
124 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)
125 format.html { redirect_to '/home/scrolls' }
126 format.json { head :ok }
128 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Scroll.model_name.human)
129 format.html { redirect_to @item }
130 format.json { render json: @item.errors, status: :unprocessable_entity }