1 class SheetPanelsController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
4 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
6 before_filter :authenticate_reader, :only => [
7 :index, :show, :by_sheet, :by_panel, :by_author
9 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
31 respond_to do |format|
32 show_prof_format format
33 format.json { render json: @item.sheet_panel_as_json(@operators.author) }
46 @sheet_panel = SheetPanel.new
47 @sheet_panel.supply_default
48 @sheet_panel.attributes = params[:sheet_panel]
49 @sheet_panel.overwrite @operators
50 @sheet = Sheet.edit(@sheet_panel.sheet_id, @operators) if @sheet_panel.sheet_id
51 @panel = Panel.show(@sheet_panel.panel_id, @operators) if @sheet_panel.panel_id
53 respond_to do |format|
54 if @sheet_panel.store @operators
55 flash[:notice] = I18n.t('flash.notice.created', :model => SheetPanel.model_name.human)
56 format.html { redirect_to play_sheet_path(@sheet) }
57 format.json { render json: @sheet_panel.sheet_panel_as_json(@operators.author) }
59 flash[:notice] = I18n.t('flash.notice.not_created', :model => SheetPanel.model_name.human)
60 format.html { render action: "new" }
61 format.json { render json: @sheet_panel.errors, status: :unprocessable_entity }
67 @sheet_panel = SheetPanel.edit(params[:id], @operators)
69 @sheet_panel.attributes = params[:sheet_panel]
70 @sheet_panel.overwrite @operators
71 @sheet = Sheet.edit(@sheet_panel.sheet_id, @operators) if @sheet_panel.sheet_id
72 respond_to do |format|
73 if @sheet_panel.store @operators, ot
74 flash[:notice] = I18n.t('flash.notice.updated', :model => SheetPanel.model_name.human)
75 format.html { redirect_to play_sheet_path(@sheet) }
76 format.json { head :ok }
78 flash[:notice] = I18n.t('flash.notice.not_updated', :model => SheetPanel.model_name.human)
79 format.html { render action: "edit" }
80 format.json { render json: @sheet_panel.errors, status: :unprocessable_entity }
86 @sheet_panel = SheetPanel.edit(params[:id], @operators)
87 @sheet = Sheet.edit(@sheet_panel.sheet_id, @operators) if @sheet_panel.sheet_id
88 respond_to do |format|
89 if @sheet_panel.destroy_and_shorten
90 flash[:notice] = I18n.t('flash.notice.destroyed', :model => SheetPanel.model_name.human)
91 format.html { redirect_to play_sheet_path(@sheet) }
92 format.json { head :ok }
94 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => SheetPanel.model_name.human)
95 format.html { redirect_to sheet_panel_path(@sheet_panel) }
96 format.json { render json: @sheet_panel.errors, status: :unprocessable_entity }