Skip to content

Commit

Permalink
fix: Link chat log button to chatlog SessionPresentation if available (
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-richards committed Feb 11, 2023
1 parent 6c31c73 commit 45e8f68
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ietf/meeting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
22 changes: 20 additions & 2 deletions ietf/meeting/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())

0 comments on commit 45e8f68

Please sign in to comment.