Skip to content

Commit fe7fc4b

Browse files
fix: miscellaneous tz fixes (ietf-tools#4481)
* fix: use meeting timezone for date comparison in agenda.html * fix: use meeting timezone in interim_meeting_cancellation_notice.txt * fix: use meeting timezone in interim_session_cancellation_notice.txt * fix: use meeting timezone for secr misc sessions tab * fix: use meeting tz for editing misc sessions * fix: handle times with day outside usual choices in secr app * fix: handle TZ correctly for reg sessions and timeslots in secr app * fix: handle timezone in session_schedule_notification.txt * fix: fix broken references in interim session cancellation template * test: use meeting timezone as element id for meeting/timeslot editing
1 parent cabb82e commit fe7fc4b

11 files changed

Lines changed: 71 additions & 38 deletions

ietf/meeting/tests_js.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,32 @@ def test_edit_meeting_schedule(self):
271271
# modal_open.click()
272272

273273
self.assertTrue(self.driver.find_element(By.CSS_SELECTOR, "#timeslot-group-toggles-modal").is_displayed())
274-
self.driver.find_element(By.CSS_SELECTOR, "#timeslot-group-toggles-modal [value=\"{}\"]".format("ts-group-{}-{}".format(slot2.time.strftime("%Y%m%d-%H%M"), int(slot2.duration.total_seconds() / 60)))).click()
274+
self.driver.find_element(
275+
By.CSS_SELECTOR,
276+
"#timeslot-group-toggles-modal [value=\"{}\"]".format(
277+
"ts-group-{}-{}".format(
278+
slot2.time.astimezone(slot2.tz()).strftime("%Y%m%d-%H%M"),
279+
int(slot2.duration.total_seconds() / 60),
280+
),
281+
),
282+
).click()
275283
self.driver.find_element(By.CSS_SELECTOR, "#timeslot-group-toggles-modal [data-bs-dismiss=\"modal\"]").click()
276284
self.assertTrue(not self.driver.find_element(By.CSS_SELECTOR, "#timeslot-group-toggles-modal").is_displayed())
277285

278286
# swap days
279-
self.driver.find_element(By.CSS_SELECTOR, ".day .swap-days[data-dayid=\"{}\"]".format(slot4.time.date().isoformat())).click()
287+
self.driver.find_element(
288+
By.CSS_SELECTOR,
289+
".day .swap-days[data-dayid=\"{}\"]".format(
290+
slot4.time.astimezone(slot4.tz()).date().isoformat(),
291+
),
292+
).click()
280293
self.assertTrue(self.driver.find_element(By.CSS_SELECTOR, "#swap-days-modal").is_displayed())
281-
self.driver.find_element(By.CSS_SELECTOR, "#swap-days-modal input[name=\"target_day\"][value=\"{}\"]".format(slot1.time.date().isoformat())).click()
294+
self.driver.find_element(
295+
By.CSS_SELECTOR,
296+
"#swap-days-modal input[name=\"target_day\"][value=\"{}\"]".format(
297+
slot1.time.astimezone(slot1.tz()).date().isoformat(),
298+
),
299+
).click()
282300
self.driver.find_element(By.CSS_SELECTOR, "#swap-days-modal button[type=\"submit\"]").click()
283301

284302
self.assertTrue(self.driver.find_elements(By.CSS_SELECTOR, '#timeslot{} #session{}'.format(slot4.pk, s1.pk)),
@@ -430,21 +448,24 @@ def test_past_swap_days_buttons(self):
430448

431449
past_swap_days_buttons = self.driver.find_elements(By.CSS_SELECTOR,
432450
','.join(
433-
'.swap-days[data-start="{}"]'.format(ts.time.date().isoformat()) for ts in past_timeslots
451+
'.swap-days[data-start="{}"]'.format(ts.time.astimezone(ts.tz()).date().isoformat())
452+
for ts in past_timeslots
434453
)
435454
)
436455
self.assertEqual(len(past_swap_days_buttons), len(past_timeslots), 'Missing past swap days buttons')
437456

438457
future_swap_days_buttons = self.driver.find_elements(By.CSS_SELECTOR,
439458
','.join(
440-
'.swap-days[data-start="{}"]'.format(ts.time.date().isoformat()) for ts in future_timeslots
459+
'.swap-days[data-start="{}"]'.format(ts.time.astimezone(ts.tz()).date().isoformat())
460+
for ts in future_timeslots
441461
)
442462
)
443463
self.assertEqual(len(future_swap_days_buttons), len(future_timeslots), 'Missing future swap days buttons')
444464

445465
now_swap_days_buttons = self.driver.find_elements(By.CSS_SELECTOR,
446466
','.join(
447-
'.swap-days[data-start="{}"]'.format(ts.time.date().isoformat()) for ts in now_timeslots
467+
'.swap-days[data-start="{}"]'.format(ts.time.astimezone(ts.tz()).date().isoformat())
468+
for ts in now_timeslots
448469
)
449470
)
450471
# only one "now" button because both sessions are on the same day
@@ -495,7 +516,8 @@ def test_past_swap_days_buttons(self):
495516
self.assertFalse(
496517
any(radio.is_enabled()
497518
for radio in modal.find_elements(By.CSS_SELECTOR, ','.join(
498-
'input[name="target_day"][value="{}"]'.format(ts.time.date().isoformat()) for ts in past_timeslots)
519+
'input[name="target_day"][value="{}"]'.format(ts.time.astimezone(ts.tz()).date().isoformat())
520+
for ts in past_timeslots)
499521
)),
500522
'Past day is enabled in swap-days modal for official schedule',
501523
)
@@ -504,14 +526,16 @@ def test_past_swap_days_buttons(self):
504526
self.assertTrue(
505527
all(radio.is_enabled()
506528
for radio in modal.find_elements(By.CSS_SELECTOR, ','.join(
507-
'input[name="target_day"][value="{}"]'.format(ts.time.date().isoformat()) for ts in enabled_timeslots)
529+
'input[name="target_day"][value="{}"]'.format(ts.time.astimezone(ts.tz()).date().isoformat())
530+
for ts in enabled_timeslots)
508531
)),
509532
'Future day is not enabled in swap-days modal for official schedule',
510533
)
511534
self.assertFalse(
512535
any(radio.is_enabled()
513536
for radio in modal.find_elements(By.CSS_SELECTOR, ','.join(
514-
'input[name="target_day"][value="{}"]'.format(ts.time.date().isoformat()) for ts in now_timeslots)
537+
'input[name="target_day"][value="{}"]'.format(ts.time.astimezone(ts.tz()).date().isoformat())
538+
for ts in now_timeslots)
515539
)),
516540
'"Now" day is enabled in swap-days modal for official schedule',
517541
)

ietf/meeting/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ def agenda(request, num=None, name=None, base=None, ext=None, owner=None, utc=""
15771577
"updated": updated,
15781578
"filter_categories": filter_organizer.get_filter_categories(),
15791579
"non_area_keywords": filter_organizer.get_non_area_keywords(),
1580-
"now": timezone.now().astimezone(pytz.utc),
1580+
"now": timezone.now().astimezone(meeting.tz()),
15811581
"display_timezone": display_timezone,
15821582
"is_current_meeting": is_current_meeting,
15831583
"use_codimd": True if meeting.date>=settings.MEETING_USES_CODIMD_DATE else False,

ietf/secr/meetings/forms.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ def get_day_choices(self):
166166
for n in range(-self.meeting.days, self.meeting.days):
167167
date = start + datetime.timedelta(days=n)
168168
choices.append((n, date.strftime("%a %b %d")))
169+
# make sure the choices include the initial day
170+
if self.initial and 'day' in self.initial:
171+
day = self.initial['day']
172+
date = start + datetime.timedelta(days=day)
173+
datestr = date.strftime("%a %b %d")
174+
if day < -self.meeting.days:
175+
choices.insert(0, (day, datestr))
176+
elif day >= self.meeting.days:
177+
choices.append((day, datestr))
169178
return choices
170179

171180

ietf/secr/meetings/views.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def misc_session_edit(request, meeting_id, schedule_name, slot_id):
558558
'name':session.name,
559559
'short':session.short,
560560
'day':delta.days,
561-
'time':slot.time.strftime('%H:%M'),
561+
'time':slot.time.astimezone(meeting.tz()).strftime('%H:%M'),
562562
'duration':duration_string(slot.duration),
563563
'show_location':slot.show_location,
564564
'purpose': session.purpose,
@@ -813,13 +813,20 @@ def times_edit(request, meeting_id, schedule_name, time):
813813
parts = [ int(x) for x in time.split(':') ]
814814
dtime = make_aware(datetime.datetime(*parts), meeting.tz())
815815
timeslots = TimeSlot.objects.filter(meeting=meeting,time=dtime)
816+
day = (dtime.date() - meeting.date) // datetime.timedelta(days=1)
817+
initial = {'day': day,
818+
'time': dtime.strftime('%H:%M'),
819+
'duration': timeslots.first().duration,
820+
'name': timeslots.first().name}
816821

817822
if request.method == 'POST':
818823
button_text = request.POST.get('submit', '')
819824
if button_text == 'Cancel':
820825
return redirect('ietf.secr.meetings.views.times', meeting_id=meeting_id,schedule_name=schedule_name)
821826

822-
form = TimeSlotForm(request.POST, meeting=meeting)
827+
# Pass "initial" even for a POST so the choices initialize correctly if day is outside
828+
# the standard set of options. See TimeSlotForm.get_day_choices().
829+
form = TimeSlotForm(request.POST, initial=initial, meeting=meeting)
823830
if form.is_valid():
824831
day = form.cleaned_data['day']
825832
time = get_timeslot_time(form, meeting)
@@ -838,13 +845,6 @@ def times_edit(request, meeting_id, schedule_name, time):
838845
else:
839846
# we need to pass the session to the form in order to disallow changing
840847
# of group after materials have been uploaded
841-
day = dtime.strftime('%w')
842-
if day == 6:
843-
day = -1
844-
initial = {'day':day,
845-
'time':dtime.strftime('%H:%M'),
846-
'duration':timeslots.first().duration,
847-
'name':timeslots.first().name}
848848
form = TimeSlotForm(initial=initial, meeting=meeting)
849849

850850
return render(request, 'meetings/times_edit.html', {

ietf/secr/templates/meetings/misc_sessions.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "meetings/base_rooms_times.html" %}
2-
{% load agenda_custom_tags %}
2+
{% load agenda_custom_tags tz %}
33
{% block subsection %}
4-
4+
{% timezone meeting.time_zone %}
55
<div class="module">
66
<h2>TimeSlots</h2>
77

@@ -73,7 +73,7 @@ <h3>No timeslots exist for this meeting. Add rooms with the "duplicate timeslots
7373

7474
</div> <!-- module -->
7575

76-
76+
{% endtimezone %}
7777
{% endblock %}
7878

7979
{% block extrahead %}

ietf/secr/templates/meetings/regular_session_edit.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "base_site.html" %}
2-
{% load staticfiles %}
2+
{% load staticfiles tz %}
33

44
{% block title %}Meetings{% endblock %}
55

@@ -19,7 +19,7 @@ <h2>Edit Session</h2>
1919

2020
<form id="meetings-schedule-form" method="post">{% csrf_token %}
2121
<div class="inline-related{% if forloop.last %} last-related{% endif %}">
22-
<table class="full-width amstable">
22+
<table class="full-width amstable">{% timezone meeting.time_zone %}
2323
<tbody>
2424
<tr>
2525
<th scope="row">Day:</th>
@@ -40,7 +40,7 @@ <h2>Edit Session</h2>
4040
<!-- [html-validate-disable-block element-required-attributes -- FIXME: as_table renders without scope] -->
4141
{{ form.as_table }}
4242
</tbody>
43-
</table>
43+
{% endtimezone %}</table>
4444
</div> <!-- inline-related -->
4545

4646
<div class="button-group">

ietf/secr/templates/meetings/session_schedule_notification.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Dear {{ to_name }},
1+
{% load tz %}{% timezone meeting.time_zone %}Dear {{ to_name }},
22

33
The session(s) that you have requested have been scheduled.
44
Below is the scheduled session information followed by
@@ -16,4 +16,4 @@ iCalendar: {{ baseurl }}{% url "ietf.meeting.views.agenda_ical" num=meeting.numb
1616

1717
Request Information:
1818

19-
{% include "includes/session_info.txt" %}
19+
{% include "includes/session_info.txt" %}{% endtimezone %}

ietf/secr/templates/meetings/sessions.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "meetings/base_rooms_times.html" %}
2-
{% load django_bootstrap5 %}
2+
{% load django_bootstrap5 tz %}
33

44
{% block subsection %}
55

@@ -18,7 +18,7 @@ <h2>Sessions</h2>
1818
<th scope="col"></th>
1919
</tr>
2020
</thead>
21-
<tbody>
21+
<tbody>{% timezone meeting.time_zone %}
2222
{% for session in sessions %}
2323
<tr>
2424
<td>{{ session.group.acronym }}</td>
@@ -46,7 +46,7 @@ <h2>Sessions</h2>
4646
</td>
4747
</tr>
4848
{% endfor %}
49-
</tbody>
49+
{% endtimezone %}</tbody>
5050
</table>
5151
</div> <!-- module -->
5252

ietf/secr/templates/meetings/times.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "meetings/base_rooms_times.html" %}
2-
2+
{% load tz %}
33
{% block subsection %}
44

55
<div class="module">
@@ -16,7 +16,7 @@ <h2>Times</h2>
1616
<th scope="col"></th>
1717
</tr>
1818
</thead>
19-
<tbody>
19+
<tbody>{% timezone meeting.time_zone %}
2020
{% for item in times %}
2121
<tr class="{% cycle 'row1' 'row2' %}">
2222
<td>{{ item.time|date:"D M d" }}</td>
@@ -26,7 +26,7 @@ <h2>Times</h2>
2626
<td><a href="{% url "ietf.secr.meetings.views.times_delete" meeting_id=meeting.number schedule_name=schedule.name time=item.time|date:"Y:m:d:H:i" %}">Delete</a></td>
2727
</tr>
2828
{% endfor %}
29-
</tbody>
29+
{% endtimezone %}</tbody>
3030
</table>
3131
{% else %}
3232
<h3>No timeslots exist for this meeting. Add rooms with the "duplicate timeslots" option enabled to copy timeslots from the last meeting.</h3>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{% load ams_filters %}
1+
{% load ams_filters tz %}{% timezone meeting.time_zone %}
22
The {{ group.name }} ({{ group.acronym }}) {% if not meeting.city %}virtual {% endif %}{% if is_multi_day %}multi-day {% endif %}
33
interim meeting for {{ meeting.date|date:"Y-m-d" }} from {{ start_time|time:"H:i" }} to {{ end_time|time:"H:i" }} {{ meeting.time_zone }}
44
has been cancelled.
55

66
{{ meeting.session_set.0.agenda_note }}
7-
7+
{% endtimezone %}
88

0 commit comments

Comments
 (0)