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:
Jennifer Richards 2022-11-30 17:31:40 -04:00 committed by GitHub
parent e56135a30c
commit b8dbd65f76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 21 deletions

View file

@ -1621,30 +1621,27 @@ class EditTimeslotsTests(IetfSeleniumTestCase):
self.do_delete_timeslot_test(cancel=True)
def do_delete_time_interval_test(self, cancel=False):
delete_day = self.meeting.date
delete_time = datetime.time(hour=10)
other_day = self.meeting.get_meeting_date(1)
other_time = datetime.time(hour=12)
delete_time_local = datetime_from_date(self.meeting.date, self.meeting.tz()).replace(hour=10)
delete_time = delete_time_local.astimezone(datetime.timezone.utc)
duration = datetime.timedelta(minutes=60)
delete: [TimeSlot] = TimeSlotFactory.create_batch(
2,
meeting=self.meeting,
time=datetime_from_date(delete_day, self.meeting.tz()).replace(hour=delete_time.hour),
time=delete_time_local,
duration=duration,
)
keep: [TimeSlot] = [
TimeSlotFactory(
meeting=self.meeting,
time=datetime_from_date(day, self.meeting.tz()).replace(hour=time.hour),
time=keep_time,
duration=duration
)
for (day, time) in (
# combinations of day/time that should not be deleted
(delete_day, other_time),
(other_day, delete_time),
(other_day, other_time),
for keep_time in (
# same day, but 2 hours later
delete_time + datetime.timedelta(hours=2),
# next day, but same wall clock 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 '
'.delete-button[data-delete-scope="column"]'
'[data-col-id="{}T{}-{}"]'.format(
delete_day.isoformat(),
delete_time.strftime('%H:%M'),
self.meeting.tz().localize(
datetime.datetime.combine(delete_day, delete_time) + duration
).strftime(
'%H:%M'
))
delete_time_local.date().isoformat(),
delete_time_local.strftime('%H:%M'),
(delete_time + duration).astimezone(self.meeting.tz()).strftime('%H:%M'))
)
self.do_delete_test(selector, keep, delete, cancel)

View file

@ -1,8 +1,8 @@
<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 %}"
data-timeslot-pk="{{ ts.pk }}"
data-date-id="{{ ts.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-date-id="{{ ts.local_start_time.date.isoformat }}"{# used for identifying day/col 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-type="{{ ts.type.slug }}"
data-timeslot-location="{{ ts.location.name }}"