From 7c9aa36982312f523c57159ace9e844fb47fb264 Mon Sep 17 00:00:00 2001 From: Mark Donnelly Date: Sat, 4 Nov 2023 15:35:51 +0000 Subject: [PATCH 1/3] Display document expiration in UTC The document expiration mail displays the date of the upcoming document expiration, but different timezones makes that date ambituous. Instead, clearly show that as a timestamp in UTC. Fixes #1825 --- ietf/doc/expire.py | 12 +++++++++--- ietf/doc/tests_draft.py | 1 + ietf/templates/doc/draft/expire_warning_email.txt | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ietf/doc/expire.py b/ietf/doc/expire.py index f6779e04718..bfb3ecc6f51 100644 --- a/ietf/doc/expire.py +++ b/ietf/doc/expire.py @@ -8,6 +8,7 @@ import datetime, os, shutil, glob, re from pathlib import Path +from zoneinfo import ZoneInfo from typing import List, Optional # pyflakes:ignore @@ -86,10 +87,15 @@ def send_expire_warning_for_draft(doc): (doc.get_state_slug("draft") != "active")): return # don't warn about dead or inactive documents - expiration = doc.expires.astimezone(DEADLINE_TZINFO).date() + expiration = doc.expires.astimezone( + DEADLINE_TZINFO + ).replace( + hour=0, minute=0, second=0, microsecond=0 + ).astimezone( + ZoneInfo('UTC') + ) now_plus_12hours = timezone.now() + datetime.timedelta(hours=12) - soon = now_plus_12hours.date() - if expiration <= soon: + if expiration <= now_plus_12hours: # The document will expire very soon, which will send email to the # same people, so do not send the warning at this point in time return diff --git a/ietf/doc/tests_draft.py b/ietf/doc/tests_draft.py index bf88b0f28d0..8dd92d27a8f 100644 --- a/ietf/doc/tests_draft.py +++ b/ietf/doc/tests_draft.py @@ -711,6 +711,7 @@ def test_warn_expirable_drafts(self): self.assertTrue('draft-ietf-mars-test@' in outbox[-1]['To']) # Gets the authors self.assertTrue('mars-chairs@ietf.org' in outbox[-1]['Cc']) self.assertTrue('aread@' in outbox[-1]['Cc']) + self.assertIn('UTC' , get_payload_text(outbox[-1])) # hack into expirable state to expire in 10 hours draft.expires = timezone.now() + datetime.timedelta(hours=10) diff --git a/ietf/templates/doc/draft/expire_warning_email.txt b/ietf/templates/doc/draft/expire_warning_email.txt index d43fadacec3..4b739b15476 100644 --- a/ietf/templates/doc/draft/expire_warning_email.txt +++ b/ietf/templates/doc/draft/expire_warning_email.txt @@ -1,7 +1,7 @@ -{% load ietf_filters %}{% autoescape off %}The following Internet-Draft will expire soon: +{% load ietf_filters tz %}{% autoescape off %}The following Internet-Draft will expire soon: Name: {{ doc.name|clean_whitespace }} Title: {{ doc.title}} State: {{ state }} -Expires: {{ expiration }} (in {{ expiration|timeuntil }}) +Expires: {{ expiration|utc }} (in {{ expiration|timeuntil }}) {% endautoescape %} From 3bc6354519550c5652b558f4cbae15b63829af36 Mon Sep 17 00:00:00 2001 From: Mark Donnelly Date: Sat, 4 Nov 2023 15:38:42 +0000 Subject: [PATCH 2/3] Remove a pair of unused files Two templates seem related to the expiration notifications, but they aren't actually used. Get rid of them. --- ietf/templates/notify_expirations/body.txt | 7 ------- ietf/templates/notify_expirations/subject.txt | 1 - 2 files changed, 8 deletions(-) delete mode 100644 ietf/templates/notify_expirations/body.txt delete mode 100644 ietf/templates/notify_expirations/subject.txt diff --git a/ietf/templates/notify_expirations/body.txt b/ietf/templates/notify_expirations/body.txt deleted file mode 100644 index e734068bb40..00000000000 --- a/ietf/templates/notify_expirations/body.txt +++ /dev/null @@ -1,7 +0,0 @@ -{% load ietf_filters %}{% autoescape off %}The following Internet-Draft will expire soon: - -Filename: {{draft.filename}} -Title: {{draft.title|clean_whitespace}} -State: {{draft.idstate}} -Expires: {{expiration}} (in {{expiration|timeuntil}}) -{% endautoescape %} diff --git a/ietf/templates/notify_expirations/subject.txt b/ietf/templates/notify_expirations/subject.txt deleted file mode 100644 index 7cb09c178b8..00000000000 --- a/ietf/templates/notify_expirations/subject.txt +++ /dev/null @@ -1 +0,0 @@ -Expiration impending: {{draft.filename}} From 602515c1bd753d65efa14ce59e736d289fe0823b Mon Sep 17 00:00:00 2001 From: Mark Donnelly Date: Thu, 9 Nov 2023 17:37:45 +0100 Subject: [PATCH 3/3] fix: remove redundant timezone conversion --- ietf/doc/expire.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ietf/doc/expire.py b/ietf/doc/expire.py index bfb3ecc6f51..0be85bea5ad 100644 --- a/ietf/doc/expire.py +++ b/ietf/doc/expire.py @@ -91,8 +91,6 @@ def send_expire_warning_for_draft(doc): DEADLINE_TZINFO ).replace( hour=0, minute=0, second=0, microsecond=0 - ).astimezone( - ZoneInfo('UTC') ) now_plus_12hours = timezone.now() + datetime.timedelta(hours=12) if expiration <= now_plus_12hours: