]> git.parisson.com Git - telemeta.git/commitdiff
search results: display collection tab by default if there's no item
authorolivier <>
Sun, 9 Mar 2008 22:56:53 +0000 (22:56 +0000)
committerolivier <>
Sun, 9 Mar 2008 22:56:53 +0000 (22:56 +0000)
telemeta/web/base.py

index fa9eb3915bf14fb081605f9b17aadf54328f5481..af14cd8fd265a171b050d530f62af904ddfb2e51 100644 (file)
@@ -110,7 +110,7 @@ class WebView(Component):
             {'continents': continents, 'countries': countries, 
             'ethnic_groups': ethnic_groups})
 
-    def search(self, request, type = 'items'):
+    def search(self, request, type = None):
         """Perform a search through collections and items metadata"""
         collections = MediaCollection.objects.all()
         items = MediaItem.objects.all()
@@ -152,6 +152,12 @@ class WebView(Component):
                 collections, items = func(value)
                 criteria[key] = value
 
+        if type is None:
+            if collections.count() and not items.count():
+                type = 'collections'
+            else:
+                type = 'items'
+
         if type == 'items':
             objects = items
         else: