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')
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)
49 list_result = @list.open(@operators,
50 {:id => params[:id], :offset => params[:offset], :count => params[:count]}
52 @items = list_result.items
53 respond_to do |format|
55 #@count = @action.list.count @item
56 #@prev_offset = @action.list.prev_offset @item
57 #@next_offset = @action.list.next_offset @item
59 @new_panel_items = assist_items('panel', 'private')
60 #@new_panel_filer = assist_filer 'panel', @new_panel_items
63 format.json { render json: @items.to_json(self.class.model.list_json_opt) }
90 @item.attributes = params[:scroll]
91 @item.overwrite @operators
94 respond_to do |format|
95 flash[:notice] = I18n.t('flash.notice.created', :model => Scroll.model_name.human)
96 format.html { redirect_to @item }
97 format.json { render json: @item.to_json(Scroll.show_json_opt), status: :created, location: @item }
100 flash[:notice] = I18n.t('flash.notice.not_created', :model => Scroll.model_name.human)
102 format.html { render action: "new" }
103 format.json { render json: @item.errors, status: :unprocessable_entity }
108 @item = Scroll.edit(params[:id], @operators)
109 @item.attributes = params[:scroll]
110 @item.overwrite @operators
111 respond_to do |format|
113 flash[:notice] = I18n.t('flash.notice.updated', :model => Scroll.model_name.human)
114 format.html { redirect_to @item }
115 format.json { head :ok }
117 flash[:notice] = I18n.t('flash.notice.not_updated', :model => Scroll.model_name.human)
118 format.html { render action: "edit" }
119 format.json { render json: @item.errors, status: :unprocessable_entity }
125 @item = Scroll.edit(params[:id], @operators)
126 respond_to do |format|
127 if @item.destroy_with_scroll_panel
128 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)
129 format.html { redirect_to '/home/scrolls' }
130 format.json { head :ok }
132 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Scroll.model_name.human)
133 format.html { redirect_to @item }
134 format.json { render json: @item.errors, status: :unprocessable_entity }