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_result = @list.open(@operators, params[:id])
+ @items = list_result.items
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('panel', 'private')
end
}
format.json { render json: @items.to_json(self.class.model.list_json_opt) }
end
end
- def count
- list_count
- end
-
- def count_by_story
- list_count
- end
-
- def count_by_panel
- list_count
- end
-
- def count_by_author
- list_count
- end
-
def new
- form_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 edit
- form_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 create
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 }
+ 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 }
+ 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_json_format format
end
end
end
-
+
def update
@sheet = Sheet.edit(params[:id], @operators)
jsn = nil
@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 }
+ 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 }
+ 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_json_format format
end
end
end
-
+
def destroy
@sheet = Sheet.edit(params[:id], @operators)
respond_to do |format|