OSDN Git Service

t#29505:md5 search wrote test on picture
[pettanr/pettanr.git] / app / controllers / pictures_controller.rb
index 64c1d9f..850ef31 100644 (file)
@@ -1,6 +1,7 @@
 class PicturesController < ApplicationController
   layout 'test' if Pettanr::Application.test_layout
-  before_filter :authenticate_user!, :only => [:show, :credit]
+  before_filter :authenticate_user!, :only => [:show, :credit, :md5]
+  before_filter :authenticate_artist, :only => [:md5]
   
   def show
     @picture = Picture.show(params[:id], @author)
@@ -24,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