From 730d39218e6ee00fcc6981073db8bdc7e14e8aac Mon Sep 17 00:00:00 2001 From: Chris Smit Date: Fri, 17 Jan 2025 09:03:07 +0200 Subject: [PATCH] Get participant data from the working version --- apps/channels/tests/test_connect_integration.py | 2 ++ apps/chat/channels.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/channels/tests/test_connect_integration.py b/apps/channels/tests/test_connect_integration.py index ed37c8fa2..890f394d4 100644 --- a/apps/channels/tests/test_connect_integration.py +++ b/apps/channels/tests/test_connect_integration.py @@ -82,6 +82,8 @@ def test_multiple_messages_are_sorted_and_concatenated(self, CommCareConnectChan def test_bot_generate_and_sends_message(self, process_input, experiment): process_input.return_value = "Hi human" commcare_connect_channel_id, encryption_key, experiment_channel, data, payload = _setup(experiment) + # The version will be used when chatting to the bot + experiment.create_new_version(make_default=True) with patch("apps.chat.channels.CommCareConnectClient") as ConnectClientMock: client_mock = ConnectClientMock.return_value diff --git a/apps/chat/channels.py b/apps/chat/channels.py index 2fbf0aebb..eb8ae03cc 100644 --- a/apps/chat/channels.py +++ b/apps/chat/channels.py @@ -825,7 +825,10 @@ def send_text_to_user(self, text: str): @cached_property def participant_data(self) -> ParticipantData: - return self.experiment.participant_data.defer("data").get(participant__identifier=self.participant_identifier) + experiment = self.experiment + if self.experiment.is_a_version: + experiment = self.experiment.working_version + return experiment.participant_data.defer("data").get(participant__identifier=self.participant_identifier) @cached_property def connect_channel_id(self) -> str: