1 class PanelsController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
4 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
6 before_filter :authenticate_reader, :only => [
7 :index, :show, :by_scroll, :by_sheet, :by_author, :by_speech_balloon_template
9 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
10 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
17 @pager = @list.page_status.pager
18 respond_to do |format|
20 list_json_format @list, format
27 if params[:mode] == 'filer'
46 def by_speech_balloon_template
50 def show_html_format format
53 @new_scroll_items = assist_items('home', 'scrolls')
54 @fresh_scroll_items = assist_items('home', 'scroll_panels').map {|sp| sp.scroll}
61 respond_to do |format|
62 show_html_format format
63 show_prof_format format
64 if params[:with_elements]
65 show_json_format_for_root format
67 show_json_format format
74 respond_to do |format|
76 @editor = Editor::PanelEditor.new @item, @operators
77 render :template => @editor.template_name, :locals => {
81 format.json { render json: @item.to_json }
87 respond_to do |format|
89 @editor = Editor::PanelEditor.new @item, @operators
90 render :template => @editor.template_name, :locals => {
94 format.json { render json: @item.to_json }
100 @item = @my_model_class.new
101 # @item.boosts 'post'
104 jsn = JSON.parse_no_except(params[:json])
106 @prm = if params[:panel] == nil or params[:panel].empty?
111 @item.class.fold_extend_settings @prm
113 respond_to do |format|
114 if @item.store @prm, @operators
115 created_html_format format
116 created_json_format format
119 flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
120 @editor = Editor::PanelEditor.new @item, @operators
121 render :template => @editor.template_name, :locals => {
125 not_created_json_format format
131 @item = Panel.edit(params[:id], @operators)
136 jsn = JSON.parse(params[:json])
138 @prm = params[:panel] || jsn
139 @item.class.fold_extend_settings @prm
140 @item.attributes = @prm
142 respond_to do |format|
143 if @item.store @prm, @operators
144 updated_html_format format
145 updated_json_format format
148 flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
149 @editor = Editor::PanelEditor.new @item, @operators
150 render :template => @editor.template_name, :locals => {
154 not_updated_json_format format
160 @item = Panel.edit(params[:id], @operators)
161 respond_to do |format|
163 if @item.destroy_with_elements
164 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
165 format.html { redirect_to '/home/panels' }
166 format.json { head :ok }
168 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
169 format.html { redirect_to @item }
170 format.json { render json: @item.errors, status: :unprocessable_entity }
177 @item = Panel.edit(params[:id], @operators)
179 respond_to do |format|
180 @operators.author.working_panel_id = @item.id
181 if @operators.author.save
182 format.html { redirect_to @item }