misc: display known format but no opening hours as all closed (#40054)

This commit is contained in:
Frédéric Péters 2020-04-15 17:08:42 +02:00
parent c6448b72ab
commit 6659113395
1 changed files with 7 additions and 2 deletions

View File

@ -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()