From 66591133954ffeb8bfbf8885dd68f4fdca21faa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 15 Apr 2020 17:08:42 +0200 Subject: [PATCH] misc: display known format but no opening hours as all closed (#40054) --- combo_plugin_gnm/templatetags/gnm.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/combo_plugin_gnm/templatetags/gnm.py b/combo_plugin_gnm/templatetags/gnm.py index d918770..d82c2d0 100644 --- a/combo_plugin_gnm/templatetags/gnm.py +++ b/combo_plugin_gnm/templatetags/gnm.py @@ -279,6 +279,7 @@ def get_mairie_opening_hours(mairie_data): previous_week = base_datetime - datetime.timedelta(7) next_week = base_datetime + datetime.timedelta(7) for specification in mairie_data.get('openinghoursspecification', []): + known_format = True valid_from, valid_through = previous_week, next_week if specification.get('validFrom'): valid_from = parse_valid_from(specification) @@ -304,8 +305,12 @@ def get_mairie_opening_hours(mairie_data): if not (any([x['am'] for x in opening_hours_dict.values()]) or any([x['pm'] for x in opening_hours_dict.values()])): - # always closed, return None to mark unavailability - return None + # always closed, returns None if the format is unknown so it can be + # displayed as "unavailable". + if not known_format: + return None + # otherwise returns an array of closed days + return [(weekday, {'am': None, 'pm': ''}) for weekday in FR_WEEKDAYS] return [ (FR_ABBREV_WEEKDAYS_LIST[weekday], hours) for weekday, hours in opening_hours_dict.items()