OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / controllers / speeches_controller.rb
index 7e53b73..6248d6c 100644 (file)
@@ -1,24 +1,59 @@
 class SpeechesController < ApplicationController
-  before_filter :authenticate_user!, :only => [:index, :show]
-  before_filter :authenticate_admin!, :only => [:list, :browse]
-
-  # GET /speeches
-  # GET /speeches.json
+  if Manifest.manifest.magic_numbers['run_mode'] == 0
+    before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+  else
+    before_action :authenticate_reader, :only => [
+      :index, :show, 
+      :by_author, :by_speech_balloon, :by_speech_balloon_template, :by_writing_format 
+    ]
+    before_action :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
+    before_action :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+  end
+  before_action :authenticate_admin!, :only => []
+  
   def index
-    @speeches = Speech.all
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @speeches }
-    end
+    filer_list
+  end
+  
+  def by_author
+    filer_list param: params[:id]
+  end
+  
+  def by_speech_balloon
+    filer_list param: params[:id]
   end
-
-  def list
-    @speeches = Speech.all
-
+  
+  def by_speech_balloon_template
+    filer_list param: params[:id]
+  end
+  
+  def by_writing_format
+    filer_list param: params[:id]
+  end
+  
+  def show_html_format format
+    format.html {
+      @item.boosts 'post'
+      @speech = @item
+    }
+  end
+  
+  def show
+    set_show
     respond_to do |format|
-      format.html { render layout: 'system' }
-      format.json { render json: @speeches }
+      show_html_format format
+      show_prof_format format
+      show_json_format format
     end
   end
+  
+  def new
+    form_new
+  end
+  
+  def edit
+    form_edit
+  end
+  
 end