fix: use consistent timezone for IDs in timeslot editor (#4813)
* test: be more careful with timezone arithmetic Drops a test case (other day, other time) that was an unlikely corner case. It was an easy check to include with the old code but is less so with the rewrite. * fix: use consistent timezone for IDs in timeslot editor * chore: remove stray testing/debug code
This commit is contained in:
parent
e56135a30c
commit
b8dbd65f76
ietf
|
@ -1621,30 +1621,27 @@ class EditTimeslotsTests(IetfSeleniumTestCase):
|
||||||
self.do_delete_timeslot_test(cancel=True)
|
self.do_delete_timeslot_test(cancel=True)
|
||||||
|
|
||||||
def do_delete_time_interval_test(self, cancel=False):
|
def do_delete_time_interval_test(self, cancel=False):
|
||||||
delete_day = self.meeting.date
|
delete_time_local = datetime_from_date(self.meeting.date, self.meeting.tz()).replace(hour=10)
|
||||||
delete_time = datetime.time(hour=10)
|
delete_time = delete_time_local.astimezone(datetime.timezone.utc)
|
||||||
other_day = self.meeting.get_meeting_date(1)
|
|
||||||
other_time = datetime.time(hour=12)
|
|
||||||
duration = datetime.timedelta(minutes=60)
|
duration = datetime.timedelta(minutes=60)
|
||||||
|
|
||||||
delete: [TimeSlot] = TimeSlotFactory.create_batch(
|
delete: [TimeSlot] = TimeSlotFactory.create_batch(
|
||||||
2,
|
2,
|
||||||
meeting=self.meeting,
|
meeting=self.meeting,
|
||||||
time=datetime_from_date(delete_day, self.meeting.tz()).replace(hour=delete_time.hour),
|
time=delete_time_local,
|
||||||
duration=duration,
|
duration=duration,
|
||||||
)
|
)
|
||||||
|
|
||||||
keep: [TimeSlot] = [
|
keep: [TimeSlot] = [
|
||||||
TimeSlotFactory(
|
TimeSlotFactory(
|
||||||
meeting=self.meeting,
|
meeting=self.meeting,
|
||||||
time=datetime_from_date(day, self.meeting.tz()).replace(hour=time.hour),
|
time=keep_time,
|
||||||
duration=duration
|
duration=duration
|
||||||
)
|
)
|
||||||
for (day, time) in (
|
for keep_time in (
|
||||||
# combinations of day/time that should not be deleted
|
# same day, but 2 hours later
|
||||||
(delete_day, other_time),
|
delete_time + datetime.timedelta(hours=2),
|
||||||
(other_day, delete_time),
|
# next day, but same wall clock time
|
||||||
(other_day, other_time),
|
datetime_from_date(self.meeting.get_meeting_date(1), self.meeting.tz()).replace(hour=10),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1652,13 +1649,9 @@ class EditTimeslotsTests(IetfSeleniumTestCase):
|
||||||
'#timeslot-table '
|
'#timeslot-table '
|
||||||
'.delete-button[data-delete-scope="column"]'
|
'.delete-button[data-delete-scope="column"]'
|
||||||
'[data-col-id="{}T{}-{}"]'.format(
|
'[data-col-id="{}T{}-{}"]'.format(
|
||||||
delete_day.isoformat(),
|
delete_time_local.date().isoformat(),
|
||||||
delete_time.strftime('%H:%M'),
|
delete_time_local.strftime('%H:%M'),
|
||||||
self.meeting.tz().localize(
|
(delete_time + duration).astimezone(self.meeting.tz()).strftime('%H:%M'))
|
||||||
datetime.datetime.combine(delete_day, delete_time) + duration
|
|
||||||
).strftime(
|
|
||||||
'%H:%M'
|
|
||||||
))
|
|
||||||
)
|
)
|
||||||
self.do_delete_test(selector, keep, delete, cancel)
|
self.do_delete_test(selector, keep, delete, cancel)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<div id="timeslot{{ ts.pk }}"
|
<div id="timeslot{{ ts.pk }}"
|
||||||
class="timeslot {% if ts in in_official_use %}in-official-use{% elif ts in in_use %}in-unofficial-use{% endif %}"
|
class="timeslot {% if ts in in_official_use %}in-official-use{% elif ts in in_use %}in-unofficial-use{% endif %}"
|
||||||
data-timeslot-pk="{{ ts.pk }}"
|
data-timeslot-pk="{{ ts.pk }}"
|
||||||
data-date-id="{{ ts.time.date.isoformat }}"{# used for identifying day/col contents #}
|
data-date-id="{{ ts.local_start_time.date.isoformat }}"{# used for identifying day/col contents #}
|
||||||
data-col-id="{{ ts.time.date.isoformat }}T{{ ts.time|date:"H:i" }}-{{ ts.end_time|date:"H:i" }}" {# used for identifying column contents #}
|
data-col-id="{{ ts.local_start_time.date.isoformat }}T{{ ts.time|date:"H:i" }}-{{ ts.end_time|date:"H:i" }}" {# used for identifying column contents #}
|
||||||
data-timeslot-name="{{ ts.name }}"
|
data-timeslot-name="{{ ts.name }}"
|
||||||
data-timeslot-type="{{ ts.type.slug }}"
|
data-timeslot-type="{{ ts.type.slug }}"
|
||||||
data-timeslot-location="{{ ts.location.name }}"
|
data-timeslot-location="{{ ts.location.name }}"
|
||||||
|
|
Loading…
Reference in a new issue