1 class PanelsController < ApplicationController
2 layout 'test' if MagicNumber['test_layout']
3 if MagicNumber['run_mode'] == 0
4 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
5 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
7 before_filter :authenticate_reader, :only => [:index, :show]
8 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
9 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
11 before_filter :authenticate_admin!, :only => [:list, :browse]
22 @item = Panel.show(params[:id], @operators)
24 respond_to do |format|
28 @new_scrolls = Scroll.mylist(@operators.author, 1, 5)
29 @fresh_scrolls = ScrollPanel.mylist(@operators.author, 1, 5).map {|sp| sp.scroll}
30 @new_sheets = Sheet.mylist(@operators.author, 1, 5)
31 @fresh_sheets = SheetPanel.mylist(@operators.author, 1, 5).map {|sp| sp.sheet}
35 format.json { render json: @item.panel_elements_as_json }
40 @panel = {:count => Panel.visible_count}
41 respond_to do |format|
42 format.json { render json: @panel.to_json }
47 @panels = Panel.all :order => 'updated_at'
49 respond_to do |format|
50 format.html { render layout: 'system' }
51 format.json { render json: @panels }
56 @panel = Panel.find(params[:id])
58 respond_to do |format|
59 format.html { render layout: 'system' }
67 respond_to do |format|
70 format.json { render json: @panel.panel_elements_as_json }
75 @panel = Panel.edit(params[:id], @author)
76 respond_to do |format|
87 jsn = JSON.parse_no_except(params[:json])
89 @prm = params[:panel] || jsn
90 respond_to do |format|
91 if @panel.store @prm, @author
92 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
93 format.html { redirect_to @panel }
94 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
96 format.html { render action: "new" }
97 format.json { render json: @panel.errors, status: :unprocessable_entity }
103 @panel = Panel.edit(params[:id], @author)
106 jsn = JSON.parse(params[:json])
108 @prm = params[:panel] || jsn
109 respond_to do |format|
110 if @panel.store @prm, @author
111 flash[:notice] = I18n.t('flash.notice.updated', :model => Panel.model_name.human)
112 format.html { redirect_to @panel }
113 format.json { head :ok }
115 format.html { render action: "edit" }
116 format.json { render json: @panel.errors, status: :unprocessable_entity }
122 @panel = Panel.edit(params[:id], @author)
123 respond_to do |format|
125 if @panel.destroy_with_elements
126 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
127 format.html { redirect_to '/home/panels' }
128 format.json { head :ok }
130 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
131 format.html { redirect_to @panel }
132 format.json { render json: @panel.errors, status: :unprocessable_entity }
139 @panel = Panel.edit(params[:id], @author)
141 respond_to do |format|
142 @author.working_panel_id = @panel.id
144 format.html { redirect_to @panel }