1 class SpeechBalloonsController < ApplicationController
2 if Manifest.manifest.magic_numbers['run_mode'] == 0
3 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
4 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
6 before_filter :authenticate_reader, :only => [
7 :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
9 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
29 def show_html_format format
31 @speech_balloon = @item
37 respond_to do |format|
38 show_html_format format
39 show_prof_format format
40 show_json_format format
57 raise Pettanr::NotWork unless @operators.author.working_panel
58 @speech_balloon_template = SpeechBalloonTemplate.show params[:speech_balloon_template_id], @operators
60 @panel = Panel.edit(@operators.author.working_panel, @operators)
61 @speech_balloon = SpeechBalloon.new :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
63 @speech_balloon.supply_default
64 @speech_balloon.get_balloon.supply_default
65 @speech_balloon.get_speech.supply_default
67 respond_to do |format|
69 render @speech_balloon_template.engine_name + '/speech_balloons/new'
71 format.json { render :json => @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
76 @speech_balloon = SpeechBalloon.show(params[:id], @operators)
77 @speech_balloon_template = @speech_balloon.speech_balloon_template
78 @panel = Panel.edit(@speech_balloon.panel.id,@operators)
82 respond_to do |format|
84 render @speech_balloon_template.engine_name + '/speech_balloons/edit'
90 raise Pettanr::NotWork unless @operators.author.working_panel
91 SpeechBalloon.fold_extend_settings params
92 @panel = Panel.edit(@operators.author.working_panel, @operators)
93 @speech_balloon = SpeechBalloon.new
94 @speech_balloon.attributes = params[:speech_balloon]
96 @speech_balloon_template = @speech_balloon.speech_balloon_template
99 params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture
101 @speech_balloon.overwrite @panel.id
103 respond_to do |format|
104 if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon])
105 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
106 format.html { redirect_to @panel }
107 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
109 flash[:notice] = I18n.t('flash.notice.not_created', :model => SpeechBalloon.model_name.human)
111 render @speech_balloon_template.engine_name + '/speech_balloons/new'
113 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
119 SpeechBalloon.fold_extend_settings params
120 @speech_balloon = SpeechBalloon.show(params[:id], @operators)
121 @speech_balloon.attributes = params[:speech_balloon]
123 @speech_balloon_template = @speech_balloon.speech_balloon_template
124 @speech_balloon.boost
126 params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture
128 @panel = Panel.edit(@speech_balloon.panel.id, @operators)
129 @speech_balloon.overwrite @panel.id
131 respond_to do |format|
132 if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon])
133 flash[:notice] = I18n.t('flash.notice.updated', :model => SpeechBalloon.model_name.human)
134 format.html { redirect_to @speech_balloon }
135 format.json { head :ok }
137 flash[:notice] = I18n.t('flash.notice.not_updated', :model => SpeechBalloon.model_name.human)
139 render @speech_balloon.speech_balloon_template.engine_name + '/speech_balloons/edit'
141 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
147 @speech_balloon = SpeechBalloon.show(params[:id], @operators)
148 @panel = Panel.edit(@speech_balloon.panel.id, @operators)
150 respond_to do |format|
151 if @speech_balloon.remove @operators.author
152 flash[:notice] = I18n.t('flash.notice.destroyed', :model => SpeechBalloon.model_name.human)
153 format.html { redirect_to @panel }
154 format.json { head :ok }
156 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => SpeechBalloon.model_name.human)
157 format.html { redirect_to @speech_balloon }
158 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }