myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3230] branches/components: Snapshot a pack by PO


From: noreply
Subject: [myexperiment-hackers] [3230] branches/components: Snapshot a pack by POSTing to it
Date: Thu, 6 Dec 2012 10:32:02 +0000 (UTC)

Revision
3230
Author
fbacall
Date
2012-12-06 10:32:01 +0000 (Thu, 06 Dec 2012)

Log Message

Snapshot a pack by POSTing to it

Modified Paths

Diff

Modified: branches/components/config/tables.xml


(Binary files differ)

Modified: branches/components/lib/rest.rb (3229 => 3230)


--- branches/components/lib/rest.rb	2012-12-05 16:37:56 UTC (rev 3229)
+++ branches/components/lib/rest.rb	2012-12-06 10:32:01 UTC (rev 3230)
@@ -1320,7 +1320,18 @@
   case action
     when 'create':
       return rest_response(401, :reason => "Not authorised to create a pack") unless Authorization.check('create', Pack, opts[:user], nil)
-      ob = Pack.new(:contributor => opts[:user])
+      if id = opts[:query]['id']
+        ob = Pack.find_by_id(id)
+        if ob.nil?
+          return rest_response(404, :reason => "Couldn't find a Pack with id #{id}")
+        else
+          ob.snapshot!
+          return rest_get_request(ob, opts[:user], { "id" => ob.id.to_s })
+        end
+      else
+        ob = Pack.new(:contributor => opts[:user])
+      end
+
     when 'view', 'edit', 'destroy':
       ob, error = obtain_rest_resource('Pack', opts[:query]['id'], opts[:query]['version'], opts[:user], action)
     else

reply via email to

[Prev in Thread] Current Thread [Next in Thread]