From d13cc141d507cd5b8035d69fb62307d3316bd49c Mon Sep 17 00:00:00 2001 From: aceglie Date: Fri, 18 Oct 2024 10:29:32 +0200 Subject: [PATCH] added right query formatting for events start/end date. ref #554 --- .../isaw/theme/browser/event_listing.py | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/isaw.theme/isaw/theme/browser/event_listing.py b/src/isaw.theme/isaw/theme/browser/event_listing.py index 09630316..1af5fc9d 100644 --- a/src/isaw.theme/isaw/theme/browser/event_listing.py +++ b/src/isaw.theme/isaw/theme/browser/event_listing.py @@ -18,6 +18,9 @@ from isaw.theme.browser.interfaces import IEventListingView from isaw.theme.browser.interfaces import IISAWSettings from isaw.theme.browser.tiled_view import TiledListingView +from plone.app.event.browser.event_listing import EventListing +from plone.app.event.base import start_end_from_mode +from plone.app.event.base import guess_date_from @implementer(IEventListingView) @@ -35,8 +38,27 @@ def format_date(self, date): DateTime(date), True, False, self.context) return date + @property + def date(self): + dt = None + if self._date: + try: + dt = guess_date_from(self._date) + except TypeError: + pass + return dt + + @property + def _start_end(self): + start, end = start_end_from_mode(self.mode, self.date, self.context) + return start, end + def listings(self, b_start=None, b_size=None): """get a page of listings""" + req = self.request.form + self._date = 'date' in req and req['date'] or None + self.mode = 'mode' in req and req['mode'] or None + if b_size is None: b_size = self.batch_size if b_start is None: @@ -62,11 +84,15 @@ def listings(self, b_start=None, b_size=None): content_filter['start'] = {'query': DateTime(), 'range': 'min'} start = self.request.get('start') - if start: - content_filter['start'] = start end = self.request.get('end') + + start, end = self._start_end + + if start: + content_filter['start'] = {'query': start, 'range': 'min'} if end: - content_filter['end'] = end + content_filter['end'] = {'query': end, 'range': 'max'} + if is_collection: batch = self.context.results(batch=True, b_start=b_start, b_size=b_size, brains=True,