From 65bd689daa6f418f0cf5e8cd55ccfff0f9d6a845 Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Wed, 24 May 2023 11:26:19 -0400 Subject: [PATCH] fix: make chat room an overrideable property of Session (#5681) * fix: make chat room an overrideable property of Session * test: validate that /meeting/session//edit shows and sets chat room * test: validate Session.chat_room_name --- ietf/meeting/admin.py | 2 +- ietf/meeting/forms.py | 2 +- .../migrations/0004_session_chat_room.py | 18 ++++++++++++++++++ ietf/meeting/models.py | 6 +++++- ietf/meeting/tests_models.py | 8 ++++++++ ietf/meeting/tests_views.py | 2 ++ 6 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 ietf/meeting/migrations/0004_session_chat_room.py diff --git a/ietf/meeting/admin.py b/ietf/meeting/admin.py index 8c419e8a9..e975dd38a 100644 --- a/ietf/meeting/admin.py +++ b/ietf/meeting/admin.py @@ -97,7 +97,7 @@ class SchedulingEventInline(admin.TabularInline): class SessionAdmin(admin.ModelAdmin): list_display = [ - "meeting", "name", "group_acronym", "purpose", "attendees", "has_onsite_tool", "requested", "current_status" + "meeting", "name", "group_acronym", "purpose", "attendees", "has_onsite_tool", "chat_room", "requested", "current_status" ] list_filter = ["purpose", "meeting", ] raw_id_fields = ["meeting", "group", "materials", "joint_with_groups", "tombstone_for"] diff --git a/ietf/meeting/forms.py b/ietf/meeting/forms.py index f3f660b2f..822f56b97 100644 --- a/ietf/meeting/forms.py +++ b/ietf/meeting/forms.py @@ -744,7 +744,7 @@ class SessionDetailsForm(forms.ModelForm): model = Session fields = ( 'purpose', 'name', 'short', 'type', 'requested_duration', - 'on_agenda', 'agenda_note', 'has_onsite_tool', 'remote_instructions', + 'on_agenda', 'agenda_note', 'has_onsite_tool', 'chat_room', 'remote_instructions', 'attendees', 'comments', ) labels = {'requested_duration': 'Length'} diff --git a/ietf/meeting/migrations/0004_session_chat_room.py b/ietf/meeting/migrations/0004_session_chat_room.py new file mode 100644 index 000000000..9879c8c42 --- /dev/null +++ b/ietf/meeting/migrations/0004_session_chat_room.py @@ -0,0 +1,18 @@ +# Copyright The IETF Trust 2023, All Rights Reserved + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('meeting', '0003_populate_session_has_onsite_tool'), + ] + + operations = [ + migrations.AddField( + model_name='session', + name='chat_room', + field=models.CharField(blank=True, help_text='Name of Zulip stream, if different from group acronym', max_length=32), + ), + ] diff --git a/ietf/meeting/models.py b/ietf/meeting/models.py index a65271162..31a887e46 100644 --- a/ietf/meeting/models.py +++ b/ietf/meeting/models.py @@ -1052,6 +1052,7 @@ class Session(models.Model): remote_instructions = models.CharField(blank=True,max_length=1024) on_agenda = models.BooleanField(default=True, help_text='Is this session visible on the meeting agenda?') has_onsite_tool = models.BooleanField(default=False, help_text="Does this session use the officially supported onsite and remote tooling?") + chat_room = models.CharField(blank=True, max_length=32, help_text='Name of Zulip stream, if different from group acronym') tombstone_for = models.ForeignKey('Session', blank=True, null=True, help_text="This session is the tombstone for a session that was rescheduled", on_delete=models.CASCADE) @@ -1285,7 +1286,10 @@ class Session(models.Model): return self._agenda_file def chat_room_name(self): - if self.type_id=='plenary': + if self.chat_room: + return self.chat_room + # At some point, add a migration to add "plenary" chat room name to existing sessions in the database. + elif self.type_id=='plenary': return 'plenary' else: return self.group_at_the_time().acronym diff --git a/ietf/meeting/tests_models.py b/ietf/meeting/tests_models.py index 2603190fe..0ccd46271 100644 --- a/ietf/meeting/tests_models.py +++ b/ietf/meeting/tests_models.py @@ -138,3 +138,11 @@ class SessionTests(TestCase): 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()) + + def test_chat_room_name(self): + session = SessionFactory(group__acronym='xyzzy') + self.assertEqual(session.chat_room_name(), 'xyzzy') + session.type_id = 'plenary' + self.assertEqual(session.chat_room_name(), 'plenary') + session.chat_room = 'fnord' + self.assertEqual(session.chat_room_name(), 'fnord') diff --git a/ietf/meeting/tests_views.py b/ietf/meeting/tests_views.py index 449ad03a3..e65adaf0c 100644 --- a/ietf/meeting/tests_views.py +++ b/ietf/meeting/tests_views.py @@ -3975,6 +3975,7 @@ class EditTests(TestCase): 'remote_instructions': 'Do this do that', 'attendees': '103', 'comments': 'So much to say', + 'chat_room': 'xyzzy', } r = self.client.post(url, post_data) self.assertNoFormPostErrors(r) @@ -3989,6 +3990,7 @@ class EditTests(TestCase): self.assertEqual(session.remote_instructions, 'Do this do that') self.assertEqual(session.attendees, 103) self.assertEqual(session.comments, 'So much to say') + self.assertEqual(session.chat_room, 'xyzzy') # Verify return to correct schedule when sched query parameter is present other_schedule = ScheduleFactory(meeting=session.meeting)