OSDN Git Service

t#29505:md5 search wrote test on picture
[pettanr/pettanr.git] / app / controllers / pictures_controller.rb
index 4661dbf..850ef31 100644 (file)
@@ -1,21 +1,23 @@
 class PicturesController < ApplicationController
-  layout 'test' if Pettanr::TestLayout
-  before_filter :authenticate_user!, :only => [:show, :credit]
+  layout 'test' if Pettanr::Application.test_layout
+  before_filter :authenticate_user!, :only => [:show, :credit, :md5]
+  before_filter :authenticate_artist, :only => [:md5]
   
   def show
-    @picture = Picture.show(params[:id])
+    @picture = Picture.show(params[:id], @author)
 
     respond_to do |format|
       opt = {:type => @picture.mime_type, :disposition=>"inline"}
       format.png { send_data(@picture.restore(params[:subdir]), opt ) }
       format.gif { send_data(@picture.restore(params[:subdir]), opt ) }
       format.jpeg { send_data(@picture.restore(params[:subdir]), opt ) }
+      format.html 
       format.json { render :json => @picture.to_json}
     end
   end
   
   def credit
-    @picture = Picture.show(params[:id])
+    @picture = Picture.show(params[:id], @author)
 
     respond_to do |format|
       format.html { render :layout => false } # show.html.erb
@@ -23,4 +25,13 @@ class PicturesController < ApplicationController
     end
   end
   
+  def md5
+    @pictures = Picture.list_by_md5(params[:md5])
+    
+    respond_to do |format|
+      format.html
+      format.json { render json: @pictures.to_json }
+    end
+  end
+  
 end