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 => [
7 :top, :index, :show, :play, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
9 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
29 def show_html_format format
31 play_list = Locmare::ListGroup.list 'scroll_panel', 'play'
32 @play_count = play_list.count(@operators,
33 {:id => @item.id, :my_play => @item.own?(@operators)}
40 respond_to do |format|
41 show_html_format format
42 show_prof_format format
43 show_json_format format
48 @item = self.class.model.show(params[:id], @operators)
51 respond_to do |format|
53 if @item.own? @operators
54 @fresh_panel_items = assist_items('panel', 'public')
55 @new_panel_items = assist_items('panel', 'private')
58 format.json { render json: @items.to_json }
84 @item = @my_model_class.new
86 @item.attributes = params[@my_model_class.item_name]
87 @item.overwrite @operators
93 @item.attributes = params[@my_model_class.item_name]
94 @item.overwrite @operators
99 @item = Scroll.edit(params[:id], @operators)
100 respond_to do |format|
101 if @item.destroy_with_leafs
102 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Scroll.model_name.human)
103 format.html { redirect_to '/home/scrolls' }
104 format.json { head :ok }
106 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Scroll.model_name.human)
107 format.html { redirect_to @item }
108 format.json { render json: @item.errors, status: :unprocessable_entity }