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]
16 list_result = @list.open(@operators)
17 @items = list_result.items
18 @pager = list_result.paginate
19 respond_to do |format|
21 format.json { render json: @items.map{|i| i.attributes}.to_json }
28 if params[:mode] == 'filer'
47 def by_speech_balloon_template
51 def show_html_format format
54 @new_scroll_items = assist_items('home', 'scrolls')
55 @fresh_scroll_items = assist_items('home', 'scroll_panels').map {|sp| sp.scroll}
62 respond_to do |format|
63 show_html_format format
64 show_prof_format format
65 if params[:with_elements]
66 show_json_format_for_root format
68 show_json_format format
89 def count_by_speech_balloon_template
95 respond_to do |format|
97 @editor = Editor::PanelEditor.new @item, @operators
98 render :template => @editor.template_name, :locals => {
102 format.json { render json: @item.to_json }
108 respond_to do |format|
110 @editor = Editor::PanelEditor.new @item, @operators
111 render :template => @editor.template_name, :locals => {
115 format.json { render json: @item.to_json }
121 @item = @my_model_class.new
122 # @item.boosts 'post'
125 jsn = JSON.parse_no_except(params[:json])
127 @prm = if params[:panel] == nil or params[:panel].empty?
132 @item.class.fold_extend_settings @prm
134 respond_to do |format|
135 if @item.store @prm, @operators
136 created_html_format format
137 created_json_format format
140 flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
141 @editor = Editor::PanelEditor.new @item, @operators
142 render :template => @editor.template_name, :locals => {
146 not_created_json_format format
152 @item = Panel.edit(params[:id], @operators)
156 jsn = JSON.parse(params[:json])
158 @prm = params[:panel] || jsn
159 self.model.fold_extend_settings @prm
160 @item.attributes = @prm
162 respond_to do |format|
163 if @item.store @item.packed_attributes, @operators
164 updated_html_format format
165 updated_json_format format
168 flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
169 @editor = Editor::PanelEditor.new @item, @operators
170 render :template => @editor.template_name, :locals => {
174 not_updated_json_format format
180 @item = Panel.edit(params[:id], @operators)
181 respond_to do |format|
183 if @item.destroy_with_elements
184 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
185 format.html { redirect_to '/home/panels' }
186 format.json { head :ok }
188 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
189 format.html { redirect_to @item }
190 format.json { render json: @item.errors, status: :unprocessable_entity }
197 @item = Panel.edit(params[:id], @operators)
199 respond_to do |format|
200 @operators.author.working_panel_id = @item.id
201 if @operators.author.save
202 format.html { redirect_to @item }