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 format.json { render json: @items.map{|i| i.attributes}.to_json }
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
139 @item.attributes = @prm
141 respond_to do |format|
142 if @item.store @prm, @operators
143 updated_html_format format
144 updated_json_format format
147 flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
148 @editor = Editor::PanelEditor.new @item, @operators
149 render :template => @editor.template_name, :locals => {
153 not_updated_json_format format
159 @item = Panel.edit(params[:id], @operators)
160 respond_to do |format|
162 if @item.destroy_with_elements
163 flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
164 format.html { redirect_to '/home/panels' }
165 format.json { head :ok }
167 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
168 format.html { redirect_to @item }
169 format.json { render json: @item.errors, status: :unprocessable_entity }
176 @item = Panel.edit(params[:id], @operators)
178 respond_to do |format|
179 @operators.author.working_panel_id = @item.id
180 if @operators.author.save
181 format.html { redirect_to @item }