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
32 @speech_balloon = @item
38 respond_to do |format|
39 show_html_format format
40 show_prof_format format
41 show_json_format format
66 raise Pettanr::NotWork unless @operators.author.working_panel
67 SpeechBalloon.fold_extend_settings params
68 @panel = Panel.edit(@operators.author.working_panel, @operators)
69 @speech_balloon = SpeechBalloon.new
70 @speech_balloon.attributes = params[:speech_balloon]
72 @speech_balloon_template = @speech_balloon.speech_balloon_template
75 params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture
77 @speech_balloon.overwrite @panel.id
79 respond_to do |format|
80 if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon])
81 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
82 format.html { redirect_to @panel }
83 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
85 flash[:notice] = I18n.t('flash.notice.not_created', :model => SpeechBalloon.model_name.human)
87 render @speech_balloon_template.engine_name + '/speech_balloons/new'
89 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
95 SpeechBalloon.fold_extend_settings params
96 @speech_balloon = SpeechBalloon.show(params[:id], @operators)
97 @speech_balloon.attributes = params[:speech_balloon]
99 @speech_balloon_template = @speech_balloon.speech_balloon_template
100 @speech_balloon.boost
102 params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture
104 @panel = Panel.edit(@speech_balloon.panel.id, @operators)
105 @speech_balloon.overwrite @panel.id
107 respond_to do |format|
108 if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon])
109 flash[:notice] = I18n.t('flash.notice.updated', :model => SpeechBalloon.model_name.human)
110 format.html { redirect_to @speech_balloon }
111 format.json { head :ok }
113 flash[:notice] = I18n.t('flash.notice.not_updated', :model => SpeechBalloon.model_name.human)
115 render @speech_balloon.speech_balloon_template.engine_name + '/speech_balloons/edit'
117 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
123 @speech_balloon = SpeechBalloon.show(params[:id], @operators)
124 @panel = Panel.edit(@speech_balloon.panel.id, @operators)
126 respond_to do |format|
127 if @speech_balloon.remove @operators.author
128 flash[:notice] = I18n.t('flash.notice.destroyed', :model => SpeechBalloon.model_name.human)
129 format.html { redirect_to @panel }
130 format.json { head :ok }
132 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => SpeechBalloon.model_name.human)
133 format.html { redirect_to @speech_balloon }
134 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }