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, :by_speech_balloon_template, :count, :count_by_panel, :count_by_author, :count_by_speech_balloon_template
9 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
10 before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
29 def by_speech_balloon_template
33 def show_html_format format
36 @speech_balloon = @item
42 respond_to do |format|
43 show_html_format format
44 show_prof_format format
45 show_json_format format
61 def count_by_speech_balloon_template
74 raise Pettanr::NotWork unless @operators.author.working_panel
75 SpeechBalloon.fold_extend_settings params
76 @panel = Panel.edit(@operators.author.working_panel, @operators)
77 @speech_balloon = SpeechBalloon.new
78 @speech_balloon.attributes = params[:speech_balloon]
80 @speech_balloon_template = @speech_balloon.speech_balloon_template
83 params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture
85 @speech_balloon.overwrite @panel.id
87 respond_to do |format|
88 if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon])
89 flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
90 format.html { redirect_to @panel }
91 format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
93 flash[:notice] = I18n.t('flash.notice.not_created', :model => SpeechBalloon.model_name.human)
95 render @speech_balloon_template.engine_name + '/speech_balloons/new'
97 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
103 @item = SpeechBalloon.show(params[:id], @operators)
104 @speech_balloon = @item
105 @form = Locmare::Bucket.factory @item.item_name, @item, true, true, @operators
106 @form.fold_extend_settings params
107 @speech_balloon.attributes = params[:speech_balloon]
109 @speech_balloon_template = @speech_balloon.speech_balloon_template
111 params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.balloon.select_system_picture
113 @panel = Panel.edit(@speech_balloon.panel.id, @operators)
114 @speech_balloon.overwrite @panel.id
116 respond_to do |format|
117 if @speech_balloon.save
118 flash[:notice] = I18n.t('flash.notice.updated', :model => SpeechBalloon.model_name.human)
119 format.html { redirect_to @speech_balloon }
120 format.json { head :ok }
122 flash[:notice] = I18n.t('flash.notice.not_updated', :model => SpeechBalloon.model_name.human)
124 render @speech_balloon.speech_balloon_template.engine_name + '/speech_balloons/edit'
126 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
132 @speech_balloon = SpeechBalloon.show(params[:id], @operators)
133 @panel = Panel.edit(@speech_balloon.panel.id, @operators)
135 respond_to do |format|
136 if @speech_balloon.remove @operators.author
137 flash[:notice] = I18n.t('flash.notice.destroyed', :model => SpeechBalloon.model_name.human)
138 format.html { redirect_to @panel }
139 format.json { head :ok }
141 flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => SpeechBalloon.model_name.human)
142 format.html { redirect_to @speech_balloon }
143 format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }