OSDN Git Service

add editor
[pettanr/pettanr.git] / app / controllers / speeches_controller.rb
1 class SpeechesController < ApplicationController
2   if Manifest.manifest.magic_numbers['run_mode'] == 0
3     before_filter :authenticate_user, :only => []
4     before_filter :authenticate_author, :only => []
5   else
6     before_filter :authenticate_reader, :only => [:index, :show, :by_speech_balloon, :by_writing_format]
7     before_filter :authenticate_user, :only => []
8     before_filter :authenticate_author, :only => []
9   end
10   before_filter :authenticate_admin!, :only => [:list, :browse]
11
12   def self.model
13     Speech
14   end
15   
16   def index
17     public_list
18   end
19   
20   def by_speech_balloon
21     filter_list
22   end
23   
24   def by_writing_format
25     filter_list
26   end
27   
28   def show
29     @item = Speech.show(params[:id], @operators)
30     respond_to do |format|
31       format.html {
32         @speech = @item
33       }
34       format_prof format
35       format.json { render json: @item.to_json(Speech.show_json_opt) }
36     end
37   end
38   
39   def list
40     @speeches = Speech.all
41
42     respond_to do |format|
43       format.html { render layout: 'system' }
44       format.json { render json: @speeches }
45     end
46   end
47
48   def browse
49     @speech = Speech.find(params[:id])
50
51     respond_to do |format|
52       format.html { render layout: 'system' }
53       format.json { render json: @speech }
54     end
55   end
56
57 end