From ca0c69af5d6e08ba26857df18c2c19bb1940741d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 4 Jun 2012 09:21:09 +0200 Subject: [PATCH] special case search on a single number (#1138) --- tabellio/searchform/simple.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tabellio/searchform/simple.py b/tabellio/searchform/simple.py index 44cc561..65e3ce1 100644 --- a/tabellio/searchform/simple.py +++ b/tabellio/searchform/simple.py @@ -120,11 +120,18 @@ class SimpleSearchView(BrowserView): if not self.request.form.get('SearchableText'): return [] sorton = self.request.form.get('docs-sort', 'session') + search_query = self.request.form.get('SearchableText') + try: + int(search_query) + except ValueError: + kwargs = {'SearchableText': search_query} + else: + kwargs = {'nodoc': search_query} c = catalog( portal_type=['tabellio.documents.dossier', 'tabellio.documents.document', 'tabellio.documents.question'], - SearchableText=self.request.form.get('SearchableText')) + **kwargs) if sorton == 'session': cmpf = cmpfunctions.Cmp().cmp_session elif sorton == 'type':