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
75 respond_to do |format|
77 @editor = Editor::PanelEditor.new @item, @operators
78 render :template => @editor.template_name, :locals => {
82 format.json { render json: @item.to_json }
88 respond_to do |format|
90 @editor = Editor::PanelEditor.new @item, @operators
91 render :template => @editor.template_name, :locals => {
95 format.json { render json: @item.to_json }
101 @item = @my_model_class.new
102 # @item.boosts 'post'
105 jsn = JSON.parse_no_except(params[:json])
107 @prm = if params[:panel] == nil or params[:panel].empty?
112 @item.class.fold_extend_settings @prm
114 respond_to do |format|
115 if @item.store @prm, @operators
116 created_html_format format
117 created_json_format format
120 flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
121 @editor = Editor::PanelEditor.new @item, @operators
122 render :template => @editor.template_name, :locals => {
126 not_created_json_format format
132 @item = Panel.edit(params[:id], @operators)
136 jsn = JSON.parse(params[:json])
138 @prm = params[:panel] || jsn
139 self.model.fold_extend_settings @prm
140 @item.attributes = @prm
142 respond_to do |format|
143 if @item.store @item.packed_attributes, @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 }