myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2330] trunk/lib/rest.rb: added search "hack" for


From: noreply
Subject: [myexperiment-hackers] [2330] trunk/lib/rest.rb: added search "hack" for curators to list through contributables from taverna
Date: Thu, 11 Feb 2010 09:48:56 -0500 (EST)

Revision
2330
Author
dgc
Date
2010-02-11 09:48:56 -0500 (Thu, 11 Feb 2010)

Log Message

added search "hack" for curators to list through contributables from taverna

Modified Paths

Diff

Modified: trunk/lib/rest.rb (2329 => 2330)


--- trunk/lib/rest.rb	2010-02-09 15:04:40 UTC (rev 2329)
+++ trunk/lib/rest.rb	2010-02-11 14:48:56 UTC (rev 2330)
@@ -1371,6 +1371,32 @@
 
   search_query = query['query']
 
+  # Start of curation hack
+
+  if search_query[0..1].downcase == 'c:' && user &&
+      Conf.curators.include?(user.username)
+
+    bits = search_query.match("^c:([a-z]*) ([0-9]+)-([0-9]+)$")
+
+    if bits.length == 4
+
+      case bits[1]
+        when 'workflows': model = Workflow
+        when 'files': model = Blob
+        when 'packs': model = Pack
+        else return rest_response(400, :reason => "Unknown category '#{bits[1]}'")
+      end
+
+      obs = model.find(:all, :conditions => ['id >= ? AND id <= ?', bits[2], bits[3]])
+
+      obs = (obs.select do |c| c.respond_to?('contribution') == false or Authorization.is_authorized?("view", nil, c, user) end)
+
+      return produce_rest_list(req_uri, rules, query, obs, 'search', {}, user)
+    end
+  end
+
+  # End of curation hack
+
   models = [User, Workflow, Blob, Network, Pack]
 
   # parse type option

reply via email to

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