class PanelsController < ApplicationController
if Manifest.manifest.magic_numbers['run_mode'] == 0
- before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
- before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
+ before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
else
before_filter :authenticate_reader, :only => [
- :index, :show, :by_scroll, :by_sheet, :by_author, :by_speech_balloon_template, :count, :count_by_scroll, :count_by_sheet, :count_by_author, :count_by_speech_balloon_template
+ :index, :show, :by_scroll, :by_sheet, :by_author, :by_speech_balloon_template
]
- before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy, :catch]
- before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy, :catch]
+ before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
end
- def self.model
- Panel
- end
private
def panel_list
set_list
- list_result = @list.open(@operators,
- {:id => params[:id], :page => params[:page], :page_size => params[:page_size]}
- )
- @items = list_result.items
- @pager = list_result.paginate
+ @items = @list.items
+ @pager = @list.page_status.pager
respond_to do |format|
format.html
- format.json { render json: @items.to_json }
+ list_json_format @list, format
format.atom
format.rss
end
def show_html_format format
format.html {
if @operators.author
- @new_scroll_items = assist_items('scroll', 'private')
- @fresh_scroll_items = assist_items('scroll_panel', 'private').map {|sp| sp.scroll}
-
- @new_sheet_items = assist_items('sheet', 'private')
- @fresh_sheet_items = assist_items('sheet_panel', 'private').map {|sp| sp.sheet}
+ @new_scroll_items = assist_items('home', 'scrolls')
+ @fresh_scroll_items = assist_items('home', 'scroll_panels').map {|sp| sp.scroll}
end
}
end
respond_to do |format|
show_html_format format
show_prof_format format
- show_json_format format
+ if params[:with_elements]
+ show_json_format_for_root format
+ else
+ show_json_format format
+ end
end
end
-
- def count
- list_count
- end
-
- def count_by_scroll
- list_count
- end
-
- def count_by_sheet
- list_count
- end
-
- def count_by_author
- list_count
- end
-
- def count_by_speech_balloon_template
- list_count
- end
+=begin
def new
set_new
respond_to do |format|
format.json { render json: @item.to_json }
end
end
+=end
+
+ def new
+ form_new
+ end
+
+ def edit
+ form_edit
+ end
def create
- @item = Panel.new
+ set_model
+ @item = @my_model_class.new
# @item.boosts 'post'
jsn = nil
if params[:json]
created_html_format format
created_json_format format
else
- format.html {
- flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
- @editor = Editor::PanelEditor.new @item, @operators
- render :template => @editor.template_name, :locals => {
- :editor => @editor
- }
- }
+ not_created_html_format format
not_created_json_format format
end
end
def update
@item = Panel.edit(params[:id], @operators)
- @item.boost
+ @item.boosts 'post'
jsn = nil
if params[:json]
jsn = JSON.parse(params[:json])
end
@prm = params[:panel] || jsn
- self.model.fold_extend_settings @prm
- @item.attributes = @prm
- @item.refresh
+ @item.class.fold_extend_settings @prm
+ # @item.refresh
respond_to do |format|
- if @item.store @item.packed_attributes, @operators
+ if @item.store @prm, @operators
updated_html_format format
updated_json_format format
else
- format.html {
- flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
- @editor = Editor::PanelEditor.new @item, @operators
- render :template => @editor.template_name, :locals => {
- :editor => @editor
- }
- }
+ not_updated_html_format format
not_updated_json_format format
end
end
end
def destroy
- @item = Panel.edit(params[:id], @operators)
- respond_to do |format|
- Panel.transaction do
- if @item.destroy_with_elements
- flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
- format.html { redirect_to '/home/panels' }
- format.json { head :ok }
- else
- flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
- format.html { redirect_to @item }
- format.json { render json: @item.errors, status: :unprocessable_entity }
- end
- end
- end
+ set_model
+ @item = @my_model_class.edit(params[:id], @operators)
+ render_destroy '/home/' + @item.path_name
end
- def catch
- @item = Panel.edit(params[:id], @operators)
-
- respond_to do |format|
- @operators.author.working_panel_id = @item.id
- if @operators.author.save
- format.html { redirect_to @item }
- else
- end
- end
- end
-
end