myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2181] trunk: API bug fix and changed content-typ


From: noreply
Subject: [myexperiment-hackers] [2181] trunk: API bug fix and changed content-type to type
Date: Tue, 28 Apr 2009 11:15:53 -0400 (EDT)

Revision
2181
Author
dgc
Date
2009-04-28 11:15:53 -0400 (Tue, 28 Apr 2009)

Log Message

API bug fix and changed content-type to type

Modified Paths

Diff

Modified: trunk/config/tables.xml


(Binary files differ)

Modified: trunk/lib/rest.rb (2180 => 2181)


--- trunk/lib/rest.rb	2009-04-28 15:15:02 UTC (rev 2180)
+++ trunk/lib/rest.rb	2009-04-28 15:15:53 UTC (rev 2181)
@@ -321,7 +321,13 @@
 
       if selected
         filters.each do |attribute,value|
-          selected = false unless result.send(attribute).downcase == value.downcase
+          lhs = result.send(attribute)
+          rhs = value
+
+          lhs = lhs.downcase if lhs.class == String
+          rhs = rhs.downcase if rhs.class == String
+
+          selected = false unless lhs == rhs
         end
       end
 
@@ -428,9 +434,7 @@
 
       results = eval(args[:model]).find(:all, find_args)
 
-      return nil if results.page > results.page_count
-
-      results
+      results unless results.page > results.page_count
     }
   end
 
@@ -445,7 +449,6 @@
 
   attributes.each do |k,v|
     root[k] = v
-    puts "Setting #{k} to #{v}"
   end
 
   elements = query['elements'] ? query['elements'].split(',') : nil
@@ -548,7 +551,7 @@
     when 'PackContributableEntry'; return "#{base}/internal-pack-item.xml?id=#{ob.id}"
     when 'PackRemoteEntry';        return "#{base}/external-pack-item.xml?id=#{ob.id}"
     when 'Tagging';                return "#{base}/tagging.xml?id=#{ob.id}"
-    when 'ContentType';            return "#{base}/content-type.xml?id=#{ob.id}"
+    when 'ContentType';            return "#{base}/type.xml?id=#{ob.id}"
 
     when 'Creditation';     return "#{base}/credit.xml?id=#{ob.id}"
     when 'Attribution';     return nil
@@ -580,7 +583,7 @@
     when 'Workflow::Version';      return 'workflow'
     when 'Comment';                return 'comment'
     when 'Bookmark';               return 'favourite'
-    when 'ContentType';            return 'content-type'
+    when 'ContentType';            return 'type'
   end
 
   return 'object'
@@ -925,7 +928,7 @@
       models = args[:models]
 
       search_result = models[0].multi_solr_search(query, :limit => size, :offset => size * (page - 1), :models => models)
-      search_result.results if search_result.total >= (size * (page - 1))
+      search_result.results unless search_result.total < (size * (page - 1))
     }
   end
 
@@ -986,6 +989,17 @@
   render(:xml => doc.to_s)
 end
 
+def content_type_count(req_uri, rules, user, query)
+
+  root = XML::Node.new('type-count')
+  root << ContentType.count.to_s
+
+  doc = XML::Document.new
+  doc.root = root
+
+  render(:xml => doc.to_s)
+end
+
 def get_tagged(req_uri, rules, user, query)
 
   return rest_response(400) if query['tag'].nil?

reply via email to

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