Skip to content

Commit

Permalink
fix: use consistent timezone for IDs in timeslot editor (#4813)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jennifer-richards authored Nov 30, 2022
1 parent e56135a commit b8dbd65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
31 changes: 12 additions & 19 deletions ietf/meeting/tests_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -1621,44 +1621,37 @@ def test_delete_timeslot_cancel(self):
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),
)
]

selector = (
'#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)

Expand Down
4 changes: 2 additions & 2 deletions ietf/templates/meeting/timeslot_edit_timeslot.html
Original file line number Diff line number Diff line change
@@ -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 }}"
Expand Down

0 comments on commit b8dbd65

Please sign in to comment.