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
65 raise Pettanr::NotWork unless @operators.author.working_panel
66 SpeechBalloon.fold_extend_settings params
67 @panel = Panel.edit(@operators.author.working_panel, @operators)
68 @speech_balloon = SpeechBalloon.new
69 @speech_balloon.attributes = params[:speech_balloon]
71 @speech_balloon_template = @speech_balloon.speech_balloon_template
74 params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture
76 @speech_balloon.overwrite @panel.id
78 respond_to do |format|
79 if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon])
80 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
81 format.html { redirect_to @panel }
82 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
84 flash[:notice] = I18n.t('flash.notice.not_created', :model => SpeechBalloon.model_name.human)
86 render @speech_balloon_template.engine_name + '/speech_balloons/new'
88 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
94 SpeechBalloon.fold_extend_settings params
95 @speech_balloon = SpeechBalloon.show(params[:id], @operators)
96 @speech_balloon.attributes = params[:speech_balloon]
98 @speech_balloon_template = @speech_balloon.speech_balloon_template
101 params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture
103 @panel = Panel.edit(@speech_balloon.panel.id, @operators)
104 @speech_balloon.overwrite @panel.id
106 respond_to do |format|
107 if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon])
108 flash[:notice] = I18n.t('flash.notice.updated', :model => SpeechBalloon.model_name.human)
109 format.html { redirect_to @speech_balloon }
110 format.json { head :ok }
112 flash[:notice] = I18n.t('flash.notice.not_updated', :model => SpeechBalloon.model_name.human)
114 render @speech_balloon.speech_balloon_template.engine_name + '/speech_balloons/edit'
116 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
122 @speech_balloon = SpeechBalloon.show(params[:id], @operators)
123 @panel = Panel.edit(@speech_balloon.panel.id, @operators)
125 respond_to do |format|
126 if @speech_balloon.remove @operators.author
127 flash[:notice] = I18n.t('flash.notice.destroyed', :model => SpeechBalloon.model_name.human)
128 format.html { redirect_to @panel }
129 format.json { head :ok }
131 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => SpeechBalloon.model_name.human)
132 format.html { redirect_to @speech_balloon }
133 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }