X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fspeech_balloons_controller.rb;h=688d8cd51c61b50cd917bbc5fe7cbd1dc28bacc1;hb=69b61b39006c1951fc8c08746e884e63e50233b3;hp=4198beca375fca213a40fe93902406b51f211512;hpb=1cb0bb65ff354e3a6d185001387bf23606ff0afb;p=pettanr%2Fpettanr.git diff --git a/app/controllers/speech_balloons_controller.rb b/app/controllers/speech_balloons_controller.rb index 4198beca..688d8cd5 100644 --- a/app/controllers/speech_balloons_controller.rb +++ b/app/controllers/speech_balloons_controller.rb @@ -1,15 +1,15 @@ class SpeechBalloonsController < ApplicationController if Manifest.manifest.magic_numbers['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [ - :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author + :index, :show, :by_panel, :by_author, :by_speech_balloon_template, :count, :count_by_panel, :count_by_author, :count_by_speech_balloon_template ] - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end - + def self.model SpeechBalloon end @@ -26,6 +26,10 @@ class SpeechBalloonsController < ApplicationController filer_list end + def by_speech_balloon_template + filer_list + end + def show_html_format format format.html { @item.boosts 'post' @@ -54,86 +58,8 @@ class SpeechBalloonsController < ApplicationController list_count end - def new - form_new - end - - def edit - form_edit - end - - def create - raise Pettanr::NotWork unless @operators.author.working_panel - SpeechBalloon.fold_extend_settings params - @panel = Panel.edit(@operators.author.working_panel, @operators) - @speech_balloon = SpeechBalloon.new - @speech_balloon.attributes = params[:speech_balloon] - - @speech_balloon_template = @speech_balloon.speech_balloon_template - @speech_balloon.boost - - params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture - - @speech_balloon.overwrite @panel.id - - respond_to do |format| - if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon]) - flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human) - format.html { redirect_to @panel } - format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel } - else - flash[:notice] = I18n.t('flash.notice.not_created', :model => SpeechBalloon.model_name.human) - format.html { - render @speech_balloon_template.engine_name + '/speech_balloons/new' - } - format.json { render json: @speech_balloon.errors, status: :unprocessable_entity } - end - end - end - - def update - SpeechBalloon.fold_extend_settings params - @speech_balloon = SpeechBalloon.show(params[:id], @operators) - @speech_balloon.attributes = params[:speech_balloon] - - @speech_balloon_template = @speech_balloon.speech_balloon_template - @speech_balloon.boost - - params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture - - @panel = Panel.edit(@speech_balloon.panel.id, @operators) - @speech_balloon.overwrite @panel.id - - respond_to do |format| - if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon]) - flash[:notice] = I18n.t('flash.notice.updated', :model => SpeechBalloon.model_name.human) - format.html { redirect_to @speech_balloon } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_updated', :model => SpeechBalloon.model_name.human) - format.html { - render @speech_balloon.speech_balloon_template.engine_name + '/speech_balloons/edit' - } - format.json { render json: @speech_balloon.errors, status: :unprocessable_entity } - end - end - end - - def destroy - @speech_balloon = SpeechBalloon.show(params[:id], @operators) - @panel = Panel.edit(@speech_balloon.panel.id, @operators) - - respond_to do |format| - if @speech_balloon.remove @operators.author - flash[:notice] = I18n.t('flash.notice.destroyed', :model => SpeechBalloon.model_name.human) - format.html { redirect_to @panel } - format.json { head :ok } - else - flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => SpeechBalloon.model_name.human) - format.html { redirect_to @speech_balloon } - format.json { render json: @speech_balloon.errors, status: :unprocessable_entity } - end - end + def count_by_speech_balloon_template + list_count end end