Skip to content

Commit 448cfbb

Browse files
fix: more timezone fixes in liaisons/meeting/message apps
1 parent 2eb5723 commit 448cfbb

8 files changed

Lines changed: 66 additions & 51 deletions

File tree

ietf/liaisons/tests.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from ietf.group.models import Group
3232
from ietf.liaisons.mails import send_sdo_reminder, possibly_send_deadline_reminder
3333
from ietf.liaisons.views import contacts_from_roles, contact_email_from_role
34+
from ietf.utils.timezone import date_today, DEADLINE_TZINFO
35+
3436

3537
# -------------------------------------------------
3638
# Helper Functions
@@ -244,7 +246,7 @@ class ManagementCommandTests(TestCase):
244246
def test_check_liaison_deadlines(self):
245247
from django.core.management import call_command
246248

247-
LiaisonStatementFactory(deadline=datetime.date.today()+datetime.timedelta(days=1))
249+
LiaisonStatementFactory(deadline=date_today(DEADLINE_TZINFO)+datetime.timedelta(days=1))
248250

249251
out = io.StringIO()
250252
mailbox_before = len(outbox)
@@ -312,7 +314,7 @@ def test_add_comment(self):
312314
self.assertNotContains(r, 'Private comment')
313315

314316
def test_taken_care_of(self):
315-
liaison = LiaisonStatementFactory(deadline=datetime.date.today()+datetime.timedelta(days=1))
317+
liaison = LiaisonStatementFactory(deadline=date_today(DEADLINE_TZINFO)+datetime.timedelta(days=1))
316318

317319
url = urlreverse('ietf.liaisons.views.liaison_detail', kwargs=dict(object_id=liaison.pk))
318320
# normal get
@@ -386,7 +388,7 @@ def test_approval_process(self):
386388
self.assertTrue(liaison.liaisonstatementevent_set.filter(type='posted'))
387389

388390
def test_edit_liaison(self):
389-
liaison = LiaisonStatementFactory(deadline=datetime.date.today()+datetime.timedelta(days=1))
391+
liaison = LiaisonStatementFactory(deadline=date_today(DEADLINE_TZINFO) + datetime.timedelta(days=1))
390392
LiaisonStatementEventFactory(statement=liaison,type_id='submitted', time=timezone.now()-datetime.timedelta(days=1))
391393
LiaisonStatementEventFactory(statement=liaison,type_id='posted')
392394
from_group = liaison.from_groups.first()
@@ -698,7 +700,7 @@ def test_add_incoming_liaison(self):
698700
from_groups = [ str(g.pk) for g in Group.objects.filter(type="sdo") ]
699701
to_group = Group.objects.get(acronym="mars")
700702
submitter = Person.objects.get(user__username="marschairman")
701-
today = datetime.date.today()
703+
today = date_today()
702704
related_liaison = liaison
703705
r = self.client.post(url,
704706
dict(from_groups=from_groups,
@@ -777,7 +779,7 @@ def test_add_outgoing_liaison(self):
777779
from_group = Group.objects.get(acronym="mars")
778780
to_group = Group.objects.filter(type="sdo")[0]
779781
submitter = Person.objects.get(user__username="marschairman")
780-
today = datetime.date.today()
782+
today = date_today()
781783
related_liaison = liaison
782784
r = self.client.post(url,
783785
dict(from_groups=str(from_group.pk),
@@ -845,7 +847,7 @@ def test_add_outgoing_liaison_unapproved_post_only(self):
845847
from_group = Group.objects.get(acronym="mars")
846848
to_group = Group.objects.filter(type="sdo")[0]
847849
submitter = Person.objects.get(user__username="marschairman")
848-
today = datetime.date.today()
850+
today = date_today()
849851
r = self.client.post(url,
850852
dict(from_groups=str(from_group.pk),
851853
from_contact=submitter.email_address(),
@@ -1150,7 +1152,7 @@ def test_send_sdo_reminder(self):
11501152
self.assertTrue('ulm-liaiman@' in outbox[-1]['To'])
11511153

11521154
def test_send_liaison_deadline_reminder(self):
1153-
liaison = LiaisonStatementFactory(deadline=datetime.date.today()+datetime.timedelta(days=1))
1155+
liaison = LiaisonStatementFactory(deadline=date_today(DEADLINE_TZINFO) + datetime.timedelta(days=1))
11541156

11551157
mailbox_before = len(outbox)
11561158
possibly_send_deadline_reminder(liaison)

ietf/meeting/management/commands/update_important_dates.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from ietf.name.models import ImportantDateName
1212
from ietf.meeting.helpers import update_important_dates
1313
from ietf.meeting.models import Meeting, ImportantDate
14+
from ietf.utils.timezone import date_today
15+
1416

1517
class Command(BaseCommand):
1618

@@ -29,7 +31,7 @@ def handle(self, *args, **options):
2931
if not meeting:
3032
self.stderr.write("\nMeeting not found: %s\n" % (m, ))
3133
continue
32-
if meeting.date < datetime.date.today() + datetime.timedelta(days=max_offset):
34+
if meeting.date < date_today(meeting.tz()) + datetime.timedelta(days=max_offset):
3335
self.stderr.write("\nMeeting %s: Won't change dates for meetings in the past or close future\n" % (meeting, ))
3436
continue
3537
self.stdout.write('\n%s\n\n' % (meeting, ))

ietf/meeting/models.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from ietf.utils.decorators import memoize
4242
from ietf.utils.storage import NoLocationMigrationFileSystemStorage
4343
from ietf.utils.text import xslugify
44-
from ietf.utils.timezone import datetime_from_date
44+
from ietf.utils.timezone import datetime_from_date, date_today
4545
from ietf.utils.models import ForeignKey
4646
from ietf.utils.validators import (
4747
MaxImageSizeValidator, WrappedValidator, validate_file_size, validate_mime_type,
@@ -147,7 +147,12 @@ def end_datetime(self):
147147
return datetime_from_date(self.get_meeting_date(self.days), self.tz())
148148

149149
def get_00_cutoff(self):
150-
start_date = datetime.datetime(year=self.date.year, month=self.date.month, day=self.date.day, tzinfo=pytz.utc)
150+
start_date = datetime.datetime(
151+
year=self.date.year,
152+
month=self.date.month,
153+
day=self.date.day,
154+
tzinfo=datetime.timezone.utc,
155+
)
151156
importantdate = self.importantdate_set.filter(name_id='idcutoff').first()
152157
if not importantdate:
153158
importantdate = self.importantdate_set.filter(name_id='00cutoff').first()
@@ -1145,7 +1150,7 @@ def can_manage_materials(self, user):
11451150
return can_manage_materials(user,self.group)
11461151

11471152
def is_material_submission_cutoff(self):
1148-
return datetime.date.today() > self.meeting.get_submission_correction_date()
1153+
return date_today(self.meeting.tz()) > self.meeting.get_submission_correction_date()
11491154

11501155
def joint_with_groups_acronyms(self):
11511156
return [group.acronym for group in self.joint_with_groups.all()]

ietf/meeting/test_data.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from ietf.person.factories import PersonFactory
2121
from ietf.person.models import Person
2222
from ietf.utils.test_data import make_test_data
23+
from ietf.utils.timezone import date_today
24+
2325

2426
def make_interim_meeting(group,date,status='sched',tz='UTC'):
2527
system_person = Person.objects.get(name="(System)")
@@ -216,8 +218,8 @@ def make_meeting_test_data(meeting=None, create_interims=False):
216218
mars_session.sessionpresentation_set.add(pres)
217219

218220
# Future Interim Meetings
219-
date = datetime.date.today() + datetime.timedelta(days=365)
220-
date2 = datetime.date.today() + datetime.timedelta(days=1000)
221+
date = date_today() + datetime.timedelta(days=365)
222+
date2 = date_today() + datetime.timedelta(days=1000)
221223
ames = Group.objects.get(acronym="ames")
222224

223225
if create_interims:
@@ -229,8 +231,8 @@ def make_meeting_test_data(meeting=None, create_interims=False):
229231
return meeting
230232

231233
def make_interim_test_data(meeting_tz='UTC'):
232-
date = datetime.date.today() + datetime.timedelta(days=365)
233-
date2 = datetime.date.today() + datetime.timedelta(days=1000)
234+
date = date_today() + datetime.timedelta(days=365)
235+
date2 = date_today() + datetime.timedelta(days=1000)
234236
PersonFactory(user__username='plain')
235237
area = GroupFactory(type_id='area')
236238
ad = Person.objects.get(user__username='ad')

ietf/meeting/tests_js.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@ def setUp(self):
20442044

20452045
# Create a group with a plenary interim session for testing type filters
20462046
somegroup = GroupFactory(acronym='sg', name='Some Group')
2047-
sg_interim = make_interim_meeting(somegroup, datetime.date.today() + datetime.timedelta(days=20))
2047+
sg_interim = make_interim_meeting(somegroup, date_today() + datetime.timedelta(days=20))
20482048
sg_sess = sg_interim.session_set.first()
20492049
sg_slot = sg_sess.timeslotassignments.first().timeslot
20502050
sg_sess.purpose_id = 'plenary'

0 commit comments

Comments
 (0)