OSDN Git Service

t#32402:add file prof
[pettanr/pettanr.git] / app / controllers / system_pictures_controller.rb
index ec7d4cb..7b6da92 100644 (file)
@@ -1,6 +1,13 @@
 class SystemPicturesController < ApplicationController
   layout 'test' if MagicNumber['test_layout']
-  before_filter :authenticate_user!, :only => [:index, :show]
+  if MagicNumber['run_mode'] == 0
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
+  else
+    before_filter :authenticate_resource_reader, :only => [:index, :show]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
+  end
   before_filter :authenticate_admin!, :only => [:list, :browse, :new, :create]
 
   # GET /system_pictures
@@ -11,7 +18,13 @@ class SystemPicturesController < ApplicationController
     @system_pictures = SystemPicture.list(@page, @page_size)
 
     respond_to do |format|
-      format.html # index.html.erb
+      format.html {
+        @paginate = SystemPicture.list_paginate(@page, @page_size)
+        render :template => 'system/filer', :locals => {
+          :items => @system_pictures, :model => SystemPicture, 
+          :roles => [@user, @admin], :pager => @paginate
+        }
+      }
       format.json { render json: @system_pictures.to_json(SystemPicture.list_json_opt) }
     end
   end
@@ -19,7 +32,7 @@ class SystemPicturesController < ApplicationController
   # GET /system_pictures/1
   # GET /system_pictures/1.json
   def show
-    @system_picture = SystemPicture.show(params[:id], @author)
+    @system_picture = SystemPicture.show(params[:id], [@user, @admin, @demand_user])
     
     respond_to do |format|
       opt = {:type => @system_picture.mime_type, :disposition=>"inline"}
@@ -27,6 +40,7 @@ class SystemPicturesController < ApplicationController
       format.gif { send_data(@system_picture.restore, opt ) }
       format.jpeg { send_data(@system_picture.restore, opt ) }
       format.html # show.html.erb
+      format.prof  { render :template => 'top/prof', :layout => true }
       format.json { render json: @system_picture.to_json(SystemPicture.show_json_opt)}
     end
   end
@@ -49,27 +63,4 @@ class SystemPicturesController < ApplicationController
     end
   end
 
-  def new
-    respond_to do |format|
-      format.html # new.html.erb
-    end
-  end
-
-  # POST /system_pictures
-  # POST /system_pictures.json
-  def create
-    @imager = PettanImager.load set_image params[:system_picture][:file]
-
-    respond_to do |format|
-      @system_picture = SystemPicture.store @imager
-      if @system_picture
-        format.html { redirect_to @system_picture, notice: 'system picture was successfully created.' }
-        format.json { render json: @system_picture.to_json(SystemPicture.show_json_opt), status: :created, location: @system_picture }
-      else
-        format.html { render action: "new" }
-        format.json { render json: {}, status: :unprocessable_entity }
-      end
-    end
-  end
-
 end