OSDN Git Service

051b9da8c386a28ba854d22e77c3b5f0bbe0a550
[pettanr/pettanr.git] / app / controllers / speech_balloon_templates_controller.rb
1 class SpeechBalloonTemplatesController < ApplicationController
2   layout 'test' if MagicNumber['test_layout']
3   if MagicNumber['run_mode'] == 0
4     before_filter :authenticate_user, :only => []
5   else
6     before_filter :authenticate_reader, :only => [:index, :show]
7     before_filter :authenticate_user, :only => []
8   end
9   before_filter :authenticate_admin!, :only => [:list, :browse, :destroy]
10
11   # GET /speech_balloon_templates
12   # GET /speech_balloon_templates.json
13   def index
14     @speech_balloon_templates = SpeechBalloonTemplate.list
15
16     respond_to do |format|
17       format.html # index.html.erb
18       format.json { render json: @speech_balloon_templates.to_json(SpeechBalloonTemplate.list_json_opt) }
19     end
20   end
21
22   # GET /speech_balloon_templates/1
23   # GET /speech_balloon_templates/1.json
24   def show
25     @speech_balloon_template = SpeechBalloonTemplate.show(params[:id], [@user, @admin])
26
27     respond_to do |format|
28       format.html # show.html.erb
29       format.json {
30         render :json => @speech_balloon_template.to_json(SpeechBalloonTemplate.show_json_opt)
31       }
32       format.jsonp {
33         render :json => "callback(" + @speech_balloon_template.to_json() + ")"
34       }
35     end
36   end
37
38   def list
39     @speech_balloon_templates = SpeechBalloonTemplate.all
40
41     respond_to do |format|
42       format.html { render layout: 'system' }
43       format.json { render json: @speech_balloon_templates }
44     end
45   end
46
47   def browse
48     @speech_balloon_template = SpeechBalloonTemplate.find(params[:id])
49
50     respond_to do |format|
51       format.html { render layout: 'system' }
52       format.json { render json: @speech_balloon_template }
53     end
54   end
55
56   # DELETE /speech_balloon_templates/1
57   # DELETE /speech_balloon_templates/1.json
58   def destroy
59     @speech_balloon_template = SpeechBalloonTemplate.find(params[:id])
60     @speech_balloon_template.destroy
61
62     respond_to do |format|
63       format.html { redirect_to :action => :list }
64       format.json { head :ok }
65     end
66   end
67 end