summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2020-04-15 15:08:42 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2020-04-15 15:08:42 (GMT)
commit66591133954ffeb8bfbf8885dd68f4fdca21faa8 (patch)
treec1ca765c0447c05d9d2909eca670604f362a6aaf
parentc6448b72ab90d39dd487a6c1fba872e8b73c9508 (diff)
downloadcombo-plugin-gnm-66591133954ffeb8bfbf8885dd68f4fdca21faa8.zip
combo-plugin-gnm-66591133954ffeb8bfbf8885dd68f4fdca21faa8.tar.gz
combo-plugin-gnm-66591133954ffeb8bfbf8885dd68f4fdca21faa8.tar.bz2
misc: display known format but no opening hours as all closed (#40054)
-rw-r--r--combo_plugin_gnm/templatetags/gnm.py9
1 files 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()