fix: link to jabber logs for old meetings (#4250)

* fix: link to jabber logs for old meetings

* test: validate the URL for old Session chat logs
This commit is contained in:
Jennifer Richards 2022-07-24 10:06:23 -04:00 committed by GitHub
parent 3aab73d862
commit b4e5cfcf91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View file

@ -1266,10 +1266,13 @@ class Session(models.Model):
return settings.CHAT_URL_PATTERN.format(chat_room_name=self.chat_room_name())
def chat_archive_url(self):
# Zulip has no separate archive
if hasattr(settings,'CHAT_ARCHIVE_URL_PATTERN'):
# datatracker 8.8.0 released on 2022 July 15; before that, fall back to old log URL
if self.meeting.date <= datetime.date(2022, 7, 15):
return f'https://www.ietf.org/jabber/logs/{ self.chat_room_name() }?C=M;O=D'
elif hasattr(settings,'CHAT_ARCHIVE_URL_PATTERN'):
return settings.CHAT_ARCHIVE_URL_PATTERN.format(chat_room_name=self.chat_room_name())
else:
# Zulip has no separate archive
return self.chat_room_url()
def notes_id(self):

View file

@ -1,7 +1,9 @@
# Copyright The IETF Trust 2021, All Rights Reserved
# -*- coding: utf-8 -*-
"""Tests of models in the Meeting application"""
from ietf.meeting.factories import MeetingFactory
import datetime
from ietf.meeting.factories import MeetingFactory, SessionFactory
from ietf.stats.factories import MeetingRegistrationFactory
from ietf.utils.test_utils import TestCase
@ -49,3 +51,10 @@ class MeetingTests(TestCase):
self.assertIsNotNone(attendance)
self.assertEqual(attendance.online, 0)
self.assertEqual(attendance.onsite, 5)
class SessionTests(TestCase):
def test_chat_archive_url_with_jabber(self):
# datatracker 8.8.0 rolled out on 2022-07-15. Before that, chat logs were jabber logs hosted at www.ietf.org.
session_with_jabber = SessionFactory(group__acronym='fakeacronym', meeting__date=datetime.date(2022,7,14))
self.assertEqual(session_with_jabber.chat_archive_url(), 'https://www.ietf.org/jabber/logs/fakeacronym?C=M;O=D')