From d5423ab51364d39111a1074548d2cc63bc21edc8 Mon Sep 17 00:00:00 2001 From: olivier <> Date: Sun, 9 Mar 2008 22:56:53 +0000 Subject: [PATCH] search results: display collection tab by default if there's no item --- telemeta/web/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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: -- 2.39.5