OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / controllers / authors_controller.rb
index da74488..320d74e 100644 (file)
@@ -1,67 +1,59 @@
 class AuthorsController < ApplicationController
-  before_filter :authenticate_user!, :only => [:index, :show, :edit, :update]
-  before_filter :authenticate_admin!, :only => [:list, :browse]
-
-  def index
-    @page = Author.page params[:page]
-    @page_size = Author.page_size params[:page_size]
-    @authors = Author.list(@page, @page_size)
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render :json => @authors.to_json(Author.list_json_opt) }
-    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 show
-    @au = Author.show(params[:id], @author)
-
-    respond_to do |format|
-      format.html
-      format.json { render :json => @au.to_json(Author.show_json_opt) }
-    end
+  def index
+    filer_list
   end
-
-  def count
-    @au = {:count => Author.visible_count}
-    respond_to do |format|
-      format.json { render json: @au.to_json }
-    end
+  
+  def show_html_format format
+    format.html {
+    }
   end
   
-  def list
-    @authors = Author.all
-
+  def show
+    set_show
     respond_to do |format|
-      format.html { render layout: 'system' }
+      show_html_format format
+      show_prof_format format
+      show_json_format format
     end
   end
-
-  def browse
-    @author = Author.find(params[:id])
-
-    respond_to do |format|
-      format.html { render layout: 'system' }
-    end
+  
+  def new
+    form_new
   end
   
   def edit
-    @au = Author.edit(params[:id], @author)
+    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
-    @au = Author.edit(params[:id], @author)
-    @au.attributes = params[:author]
-    @au.overwrite
-
-    respond_to do |format|
-      if @au.save
-        format.html { redirect_to @au, notice: 'Author was successfully updated.' }
-        format.json { head :ok }
-      else
-        format.html { render action: "edit" }
-        format.json { render json: @au.errors, status: :unprocessable_entity }
-      end
-    end
+    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