From a9c8b9224fb867ae87790e6737201894d1c9f535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 10 Jun 2014 15:04:37 +0200 Subject: [PATCH] reorder dates so there's no confusion about US date format (#4670) --- src/pfwbged/collection/searchview.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pfwbged/collection/searchview.py b/src/pfwbged/collection/searchview.py index fb34482..60fa674 100644 --- a/src/pfwbged/collection/searchview.py +++ b/src/pfwbged/collection/searchview.py @@ -1,5 +1,6 @@ from collections import OrderedDict import json +import datetime from Products.CMFPlone.utils import base_hasattr @@ -406,6 +407,15 @@ class ContentListingView(BrowserView): class QueryBuilder(plone.app.querystring.querybuilder.QueryBuilder): def _makequery(self, *args, **kwargs): + for i, param in enumerate(kwargs.get('query', [])): + if param.get('o', '').startswith('plone.app.querystring.operation.date'): + date = param.get('v') + try: + param = dict(param.copy()) + param['v'] = datetime.datetime.strptime(date, '%m/%d/%Y').strftime('%Y-%m-%d') + kwargs.get('query')[i] = param + except ValueError: + pass results = plone.app.querystring.querybuilder.QueryBuilder._makequery(self, *args, **kwargs) if isinstance(results, ContentListing): # results may have been padded with None, but ContentListing