Repository: ietf-tools/datatracker

Issue:
Chat logs button should point to archived doc instead of zulip after meeting
### Describe the issue

On a past meeting materials page, the "chat logs" button at the top points to the zulip chat log. Inline in the materials list, there is a chat logs section that lists the archived chat log document. The button should point to that document to match the rest of the materials display.

E.g., https://datatracker.ietf.org/meeting/115/session/oauth

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/meeting/models.py b/ietf/meeting/models.py
--- a/ietf/meeting/models.py
+++ b/ietf/meeting/models.py
@@ -1317,8 +1317,11 @@ def chat_room_url(self):
         return settings.CHAT_URL_PATTERN.format(chat_room_name=self.chat_room_name())
 
     def chat_archive_url(self):
-        # 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):
+        chatlog = self.sessionpresentation_set.filter(document__type__slug='chatlog').first()
+        if chatlog is not None:
+            return chatlog.document.get_href()
+        elif self.meeting.date <= datetime.date(2022, 7, 15):
+            # datatracker 8.8.0 released on 2022 July 15; before that, fall back to old log URL
             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())


Test patch:
diff --git a/ietf/meeting/tests_models.py b/ietf/meeting/tests_models.py
--- a/ietf/meeting/tests_models.py
+++ b/ietf/meeting/tests_models.py
@@ -5,8 +5,11 @@
 
 from mock import patch
 
+from django.conf import settings
+from django.test import override_settings
+
 from ietf.group.factories import GroupFactory, GroupHistoryFactory
-from ietf.meeting.factories import MeetingFactory, SessionFactory, AttendedFactory
+from ietf.meeting.factories import MeetingFactory, SessionFactory, AttendedFactory, SessionPresentationFactory
 from ietf.stats.factories import MeetingRegistrationFactory
 from ietf.utils.test_utils import TestCase
 from ietf.utils.timezone import date_today, datetime_today
@@ -116,7 +119,22 @@ def test_group_at_the_time(self):
 
 
 class SessionTests(TestCase):
-    def test_chat_archive_url_with_jabber(self):
+    def test_chat_archive_url(self):
+        session = SessionFactory(
+            meeting__date=datetime.date.today(),
+            meeting__number=120,  # needs to use proceedings_format_version > 1
+        )
+        with override_settings():
+            if hasattr(settings, 'CHAT_ARCHIVE_URL_PATTERN'):
+                del settings.CHAT_ARCHIVE_URL_PATTERN
+            self.assertEqual(session.chat_archive_url(), session.chat_room_url())
+            settings.CHAT_ARCHIVE_URL_PATTERN = 'http://chat.example.com'
+            self.assertEqual(session.chat_archive_url(), 'http://chat.example.com')
+            chatlog = SessionPresentationFactory(session=session, document__type_id='chatlog').document
+            self.assertEqual(session.chat_archive_url(), chatlog.get_href())
+
         # 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')
+        chatlog = SessionPresentationFactory(session=session_with_jabber, document__type_id='chatlog').document
+        self.assertEqual(session_with_jabber.chat_archive_url(), chatlog.get_href())