OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / controllers / authors_controller.rb
index 8386ed2..320d74e 100644 (file)
@@ -1,19 +1,59 @@
 class AuthorsController < ApplicationController
-  before_filter :authenticate_author!, :only => [:index, :show]
-  def index
-    @authors = Author.all
-
-    respond_to do |format|
-      format.html # index.html.erb
-    end
+  if Manifest.manifest.magic_numbers['run_mode'] == 0
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update]
+    before_action :authenticate_author, :only => [:edit, :update]
+  else
+    before_action :authenticate_reader, :only => [:index, :show]
+    before_action :authenticate_user, :only => [:new, :create, :edit, :update]
+    before_action :authenticate_author, :only => [:edit, :update]
   end
 
+  def index
+    filer_list
+  end
+  
+  def show_html_format format
+    format.html {
+    }
+  end
+  
   def show
-    @author = Author.find(params[:id])
-
+    set_show
     respond_to do |format|
-      format.html
+      show_html_format format
+      show_prof_format format
+      show_json_format format
     end
   end
-
+  
+  def new
+    form_new
+  end
+  
+  def edit
+    form_edit
+  end
+  
+  def create
+    set_model
+    @item = @my_model_class.new
+    @item.supply_default 
+    @item.attributes = @item.permit_params params
+    @item.overwrite @operators
+    render_create root_path
+  end
+  
+  def update
+    set_edit
+    @item.attributes = @item.permit_params params
+    @item.overwrite @operators
+    render_update '/home/configure'
+  end
+  
+  def destroy
+    set_model
+    @item = @my_model_class.edit(params[:id], @operators)
+    render_destroy '/home/configure'
+  end
+  
 end