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]
27 def show_html_format format
31 @new_panel_items = assist_items('panel', 'private_list')
32 #@new_panel_filer = assist_filer 'panel', @new_panel_items
39 respond_to do |format|
40 show_html_format format
41 show_prof_format format
42 show_json_format format
47 @item = self.class.model.show(params[:id], @operators)
48 action_name = params[:action]
49 @action = self.class.controller.open(action_name, params, @operators)
50 @items = @action.list.items @item
51 respond_to do |format|
53 @count = @action.list.count @item
54 @prev_offset = @action.list.prev_offset @item
55 @next_offset = @action.list.next_offset @item
57 @new_panel_items = assist_items('panel', 'private_list')
58 @new_panel_filer = assist_filer 'panel', @new_panel_items
61 format.json { render json: @items.to_json(self.class.model.list_json_opt) }
82 @scroll = Scroll.edit(params[:id], @operators)
83 respond_to do |format|
91 @scroll.supply_default
92 @scroll.attributes = params[:scroll]
93 @scroll.overwrite @operators
95 respond_to do |format|
97 flash[:notice] = I18n.t('flash.notice.created', :model => Scroll.model_name.human)
98 format.html { redirect_to @scroll }
99 format.json { render json: @scroll.to_json(Scroll.show_json_opt), status: :created, location: @scroll }
101 flash[:notice] = I18n.t('flash.notice.not_created', :model => Scroll.model_name.human)
102 format.html { render action: "new" }
103 format.json { render json: @scroll.errors, status: :unprocessable_entity }
109 @scroll = Scroll.edit(params[:id], @operators)
110 @scroll.attributes = params[:scroll]
111 @scroll.overwrite @operators
112 respond_to do |format|
114 flash[:notice] = I18n.t('flash.notice.updated', :model => Scroll.model_name.human)
115 format.html { redirect_to @scroll }
116 format.json { head :ok }
118 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Scroll.model_name.human)
119 format.html { render action: "edit" }
120 format.json { render json: @scroll.errors, status: :unprocessable_entity }
126 @scroll = Scroll.edit(params[:id], @operators)
127 respond_to do |format|
128 if @scroll.destroy_with_scroll_panel
129 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)
130 format.html { redirect_to '/home/scrolls' }
131 format.json { head :ok }
133 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Scroll.model_name.human)
134 format.html { redirect_to @scroll }
135 format.json { render json: @scroll.errors, status: :unprocessable_entity }