OSDN Git Service

list browser created
[pettanr/pettanr.git] / app / controllers / common_lisences_controller.rb
index 35ac50d..927e460 100644 (file)
@@ -1,4 +1,7 @@
 class CommonLisencesController < ApplicationController
+  before_filter :authenticate_author!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse, :new, :edit, :create, :update, :destroy]
+
   # GET /common_lisences
   # GET /common_lisences.json
   def index
@@ -21,6 +24,24 @@ class CommonLisencesController < ApplicationController
     end
   end
 
+  def list
+    @common_lisences = CommonLisence.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @common_lisences }
+    end
+  end
+
+  def browse
+    @common_lisence = CommonLisence.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @common_lisence }
+    end
+  end
+
   # GET /common_lisences/new
   # GET /common_lisences/new.json
   def new
@@ -45,7 +66,7 @@ class CommonLisencesController < ApplicationController
     respond_to do |format|
       CommonLisence.transaction do
         if @common_lisence.save_save
-          format.html { redirect_to @common_lisence, notice: 'Common lisence was successfully created.' }
+          format.html { redirect_to :action => :browse, :id => @common_lisence.id, notice: 'Common lisence was successfully created.' }
           format.json { render json: @common_lisence, status: :created, location: @common_lisence }
         else
           format.html { render action: "new" }
@@ -62,7 +83,7 @@ class CommonLisencesController < ApplicationController
 
     respond_to do |format|
       if @common_lisence.update_attributes(params[:common_lisence])
-        format.html { redirect_to @common_lisence, notice: 'Common lisence was successfully updated.' }
+        format.html { redirect_to :action => :browse, :id => @common_lisence.id, notice: 'Common lisence was successfully updated.' }
         format.json { head :ok }
       else
         format.html { render action: "edit" }