before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
else
before_filter :authenticate_reader, :only => [
- :index, :show, :play, :by_story, :by_panel, :by_author, :count, :count_by_story, :count_by_panel, :count_by_author
+ :index, :show, :play, :by_story, :by_panel, :by_author
]
before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
end
-
- def self.model
- Sheet
- end
def index
filer_list
filer_list
end
+ def show_html_format format
+ format.html {
+ if @operators.author
+ @new_panel_items = assist_items('home', 'panels')
+
+ @new_story_items = assist_items('home', 'stories')
+ @fresh_story_items = assist_items('home', 'story_sheets').map {|ss| ss.story}
+ end
+ }
+ end
+
def show
- @item = Sheet.show(params[:id], @operators)
-
+ set_show
respond_to do |format|
- format.html {
- if @operators.author
- @new_panel_items = assist_items('panel', 'private_list')
- @new_panel_filer = assist_filer 'panel', @new_panel_items
-
- @new_story_items = assist_items('story', 'private_list')
- @new_story_filer = assist_filer 'story', @new_story_items
- @fresh_story_items = assist_items('story_sheet', 'private_list').map {|ss| ss.story}
- @fresh_story_filer = assist_filer 'story', @fresh_story_items
- end
- }
- format_prof format
- format.json { render json: @item.to_json(Sheet.show_json_opt) }
- format.atom
- format.rss
+ show_html_format format
+ show_prof_format format
+ show_json_format_for_root format
end
end
-
+
def play
- @item = self.class.model.show(params[:id], @operators)
- action_name = params[:action]
- @action = self.class.controller.open(action_name, params, @operators)
- @items = @action.list.items @item
+ set_play
+ @list.options.merge!({'page_size' => -1}) # no limit no pager
+ @list.reset
+ play_list
respond_to do |format|
format.html {
- @count = @action.list.count @item
- @prev_offset = @action.list.prev_offset @item
- @next_offset = @action.list.next_offset @item
if @operators.author
- @new_panel_items = assist_items('panel', 'private_list')
- @new_panel_filer = assist_filer 'panel', @new_panel_items
+ @new_panel_items = assist_items('home', 'panels')
end
}
- format.json { render json: @items.to_json(self.class.model.list_json_opt) }
+ list_json_format @list, format
end
end
- def count
- list_count
- end
-
- def count_by_story
- list_count
+=begin
+ def new
+ set_new
+ respond_to do |format|
+ format.html {
+ @editor = Editor::SheetEditor.new @item, @operators
+ render :template => @editor.template_name, :locals => {
+ :editor => @editor
+ }
+ }
+ format.json { render json: @item.to_json }
+ end
end
- def count_by_panel
- list_count
+ def edit
+ set_edit
+ respond_to do |format|
+ format.html {
+ @editor = Editor::SheetEditor.new @item, @operators
+ render :template => @editor.template_name, :locals => {
+ :editor => @editor
+ }
+ }
+ format.json { render json: @item.to_json }
+ end
end
- def count_by_author
- list_count
- end
+=end
def new
- @sheet = Sheet.new
- @sheet.supply_default
- respond_to do |format|
- format.html
- format.js
- format.json { render json: @sheet.to_json(Sheet.show_json_opt) }
- end
+ form_new
end
-
+
def edit
- @sheet = Sheet.edit(params[:id], @operators)
- respond_to do |format|
- format.html
- format.js
- end
+ form_edit
end
-
+
def create
- @sheet = Sheet.new
- @sheet.supply_default
+ set_model
+ @item = @my_model_class.new
+ @item.supply_default
jsn = nil
if params[:json]
jsn = JSON.parse_no_except(params[:json])
end
@prm = params[:sheet] || jsn
-
+
respond_to do |format|
- if @sheet.store @prm, @operators
- flash[:notice] = I18n.t('flash.notice.created', :model => Sheet.model_name.human)
- format.html { redirect_to @sheet }
- format.json { render json: @sheet.to_json(Sheet.show_json_opt), status: :created, location: @sheet }
+ if @item.store @prm, @operators
+ created_html_format format
+ created_json_format format
else
- flash[:notice] = I18n.t('flash.notice.not_created', :model => Sheet.model_name.human)
- format.html { render action: "new" }
- format.json { render json: @sheet.errors, status: :unprocessable_entity }
+ not_created_html_format format
+ not_created_json_format format
end
end
end
-
+
def update
- @sheet = Sheet.edit(params[:id], @operators)
+ set_edit
jsn = nil
if params[:json]
jsn = JSON.parse(params[:json])
end
@prm = params[:sheet] || jsn
respond_to do |format|
- if @sheet.store @prm, @operators
- flash[:notice] = I18n.t('flash.notice.updated', :model => Sheet.model_name.human)
- format.html { redirect_to @sheet }
- format.json { head :ok }
+ if @item.store @prm, @operators
+ updated_html_format format
+ updated_json_format format
else
- flash[:notice] = I18n.t('flash.notice.not_updated', :model => Sheet.model_name.human)
- format.html { render action: "edit" }
- format.json { render json: @sheet.errors, status: :unprocessable_entity }
+ not_updated_html_format format
+ not_updated_json_format format
end
end
end
-
+
def destroy
@sheet = Sheet.edit(params[:id], @operators)
respond_to do |format|