X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fcontrollers%2Fspeech_balloons_controller.rb;h=1d1a523b90632293d2300ce6d25f1903ba01ec68;hb=3f4cd8c9a4ce4336a659d7ad7f7093c0c1cd6ee9;hp=6e95295bb40996dd29de345217135061c214cdd5;hpb=7a49b06b1e7242f4c4ed09e2890a7220c1800548;p=pettanr%2Fpettanr.git diff --git a/app/controllers/speech_balloons_controller.rb b/app/controllers/speech_balloons_controller.rb index 6e95295b..1d1a523b 100644 --- a/app/controllers/speech_balloons_controller.rb +++ b/app/controllers/speech_balloons_controller.rb @@ -1,157 +1,61 @@ class SpeechBalloonsController < ApplicationController - layout 'test' if MagicNumber['test_layout'] - if MagicNumber['run_mode'] == 0 - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] + if Manifest.manifest.magic_numbers['run_mode'] == 0 + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else - before_filter :authenticate_reader, :only => [:index, :show] - before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] - before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] - end - before_filter :authenticate_admin!, :only => [:list, :browse] - - def self.model - SpeechBalloon + before_filter :authenticate_reader, :only => [ + :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 => [] + before_filter :authenticate_author, :only => [] end def index - public_list + filer_list end - def show - @item = SpeechBalloon.show(params[:id], @operators) - respond_to do |format| - format.html { - @speech_balloon = @item - } - format_prof format - format.json { render json: @item.to_json(SpeechBalloon.show_json_opt) } - end + def by_panel + filer_list end - def list - @speech_balloons = SpeechBalloon.all - - respond_to do |format| - format.html { render layout: 'system' } - format.json { render json: @speech_balloons } - end + def by_author + filer_list end - - def browse - @speech_balloon = SpeechBalloon.find(params[:id]) - - respond_to do |format| - format.html { render layout: 'system' } - format.json { render json: @speech_balloon } - end + + def by_speech_balloon_template + filer_list end - - def new - raise Pettanr::NotWork unless @operators.author.working_panel - @speech_balloon_template = SpeechBalloonTemplate.show params[:speech_balloon_template_id], @operators - - @panel = Panel.edit(@operators.author.working_panel, @operators) - @speech_balloon = SpeechBalloon.new :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id - @speech_balloon.boost - @speech_balloon.supply_default - @speech_balloon.get_balloon.supply_default - @speech_balloon.get_speech.supply_default - - respond_to do |format| - format.html { - render @speech_balloon_template.engine_name + '/speech_balloons/new' - } - format.json { render :json => @speech_balloon.to_json(SpeechBalloon.show_json_opt) } - end + + def show_html_format format + format.html { + @item.boosts 'post' + @speech_balloon = @item + } end - - def edit - @speech_balloon = SpeechBalloon.show(params[:id], @operators.author) - @speech_balloon_template = @speech_balloon.speech_balloon_template - @panel = Panel.edit(@speech_balloon.panel.id, @operators.author) - - @speech_balloon.boost - + + def show + set_show respond_to do |format| - format.html { - render @speech_balloon_template.engine_name + '/speech_balloons/edit' - } + show_html_format format + show_prof_format format + show_json_format format end end - - def create - raise Pettanr::NotWork unless @operators.author.working_panel - SpeechBalloon.fold_extend_settings params - @panel = Panel.edit(@operators.author.working_panel, @author) - @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(@author, 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 + + def count + list_count end - - def update - SpeechBalloon.fold_extend_settings params - @speech_balloon = SpeechBalloon.show(params[:id], @operators.author) - @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.author) - @speech_balloon.overwrite @panel.id - - respond_to do |format| - if @speech_balloon.valid? and @speech_balloon.store(@operators.author, 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 + + def count_by_panel + list_count end - - def destroy - @speech_balloon = SpeechBalloon.show(params[:id], @operators.author) - @panel = Panel.edit(@speech_balloon.panel.id, @operators.author) - - 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_author + list_count + end + + def count_by_speech_balloon_template + list_count end end