From: olivier <> Date: Sun, 9 Mar 2008 22:56:53 +0000 (+0000) Subject: search results: display collection tab by default if there's no item X-Git-Tag: 1.1~843 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d5423ab51364d39111a1074548d2cc63bc21edc8;p=telemeta.git search results: display collection tab by default if there's no item --- diff --git a/telemeta/web/base.py b/telemeta/web/base.py index fa9eb391..af14cd8f 100644 --- a/telemeta/web/base.py +++ b/telemeta/web/base.py @@ -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: