misc: rename variables in template tags (#25582)
This commit is contained in:
parent
b4a823a570
commit
72408821ff
|
@ -55,7 +55,7 @@ EN_ABBREV_WEEKDAYS = OrderedDict([
|
|||
('su', 'Sunday')
|
||||
])
|
||||
EN_ABBREV_WEEKDAYS_LIST = list(EN_ABBREV_WEEKDAYS.keys())
|
||||
WEEKDAYS = list(EN_ABBREV_WEEKDAYS.values())
|
||||
EN_FULL_WEEKDAYS_LIST = list(EN_ABBREV_WEEKDAYS.values())
|
||||
FR_ABBREV_WEEKDAYS_LIST = OrderedDict(zip(EN_ABBREV_WEEKDAYS_LIST, FR_WEEKDAYS))
|
||||
|
||||
|
||||
|
@ -79,12 +79,12 @@ def get_open_close_from_specification(specification, valid_from, base_datetime):
|
|||
closing_time = datetime.datetime.combine(base_datetime, dateutil_parse(specification['closes']).time())
|
||||
opening_time = opening_time.replace(tzinfo=valid_from.tzinfo)
|
||||
closing_time = closing_time.replace(tzinfo=valid_from.tzinfo)
|
||||
day_of_week = WEEKDAYS.index(specification['dayOfWeek'].split('/')[-1])
|
||||
day_number = EN_FULL_WEEKDAYS_LIST.index(specification['dayOfWeek'].split('/')[-1])
|
||||
opening_time = opening_time + datetime.timedelta(
|
||||
days=(7 + (day_of_week - opening_time.weekday())) % 7)
|
||||
days=(7 + (day_number - opening_time.weekday())) % 7)
|
||||
closing_time = closing_time + datetime.timedelta(
|
||||
days=(7 + (day_of_week - closing_time.weekday())) % 7)
|
||||
return (opening_time, closing_time, day_of_week)
|
||||
days=(7 + (day_number - closing_time.weekday())) % 7)
|
||||
return (opening_time, closing_time, day_number)
|
||||
|
||||
|
||||
def openinghours_to_datetime(codename, hour, minute, default=None):
|
||||
|
@ -176,7 +176,7 @@ def get_slots_from_mairie_format(data, base_datetime):
|
|||
if 'opens' in specification and 'closes' in specification:
|
||||
# case when opening periods are defined
|
||||
if base_datetime >= valid_from and base_datetime < valid_through:
|
||||
(opening_time, closing_time, day_of_week) = get_open_close_from_specification(
|
||||
(opening_time, closing_time, day_number) = get_open_close_from_specification(
|
||||
specification, valid_from, base_datetime)
|
||||
slots.append(TimeSlot(opening_time, closing_time))
|
||||
else:
|
||||
|
@ -271,9 +271,9 @@ def get_mairie_opening_hours(mairie_data):
|
|||
if 'opens' in specification and 'closes' in specification:
|
||||
# parse specification only for the current period relative to utcnow()
|
||||
if base_datetime >= valid_from and base_datetime < valid_through:
|
||||
(opening_time, closing_time, day_of_week) = get_open_close_from_specification(
|
||||
(opening_time, closing_time, day_number) = get_open_close_from_specification(
|
||||
specification, valid_from, base_datetime)
|
||||
abbr_day_of_week = EN_ABBREV_WEEKDAYS_LIST[day_of_week]
|
||||
abbr_day_of_week = EN_ABBREV_WEEKDAYS_LIST[day_number]
|
||||
(period, all_day_hours) = get_period_from_data(abbr_day_of_week,
|
||||
opening_time=opening_time, closing_time=closing_time)
|
||||
if all_day_hours and period == 'am':
|
||||
|
|
Loading…
Reference in New Issue