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)
135 jsn = JSON.parse(params[:json])
137 @prm = params[:panel] || jsn
138 @item.class.fold_extend_settings @prm
140 respond_to do |format|
141 if @item.store @prm, @operators
142 updated_html_format format
143 updated_json_format format
146 flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
147 @editor = Editor::PanelEditor.new @item, @operators
148 render :template => @editor.template_name, :locals => {
152 not_updated_json_format format
158 @item = Panel.edit(params[:id], @operators)
159 respond_to do |format|
161 if @item.destroy_with_elements
162 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
163 format.html { redirect_to '/home/panels' }
164 format.json { head :ok }
166 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
167 format.html { redirect_to @item }
168 format.json { render json: @item.errors, status: :unprocessable_entity }
175 @item = Panel.edit(params[:id], @operators)
177 respond_to do |format|
178 @operators.author.working_panel_id = @item.id
179 if @operators.author.save
180 format.html { redirect_to @item }