diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py b/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py index 9d4efb2fa77c..5bef4324d122 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.py @@ -11,6 +11,7 @@ from consent.models import DataSharingConsent from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.sites.models import Site +from django.conf import settings from django.core import mail from django.core.cache import cache from django.test import TestCase @@ -21,7 +22,6 @@ EnterpriseCustomerUser, PendingEnterpriseCustomerUser ) -from integrated_channels.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit from opaque_keys.edx.keys import CourseKey from rest_framework import status from social_django.models import UserSocialAuth @@ -87,6 +87,12 @@ setup_retirement_states ) +# This is a temporary import path while we transition from integrated_channels to channel_integrations +if getattr(settings, 'ENABLE_LEGACY_INTEGRATED_CHANNELS', True): + from integrated_channels.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit +else: + from channel_integrations.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit + def build_jwt_headers(user): """ diff --git a/openedx/core/djangoapps/user_api/accounts/views.py b/openedx/core/djangoapps/user_api/accounts/views.py index 0464187b5d7e..2a5b38fbe3fa 100644 --- a/openedx/core/djangoapps/user_api/accounts/views.py +++ b/openedx/core/djangoapps/user_api/accounts/views.py @@ -26,8 +26,6 @@ from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomerUser, PendingEnterpriseCustomerUser -from integrated_channels.degreed.models import DegreedLearnerDataTransmissionAudit -from integrated_channels.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit from rest_framework import permissions, status from rest_framework.authentication import SessionAuthentication from rest_framework.exceptions import UnsupportedMediaType @@ -97,6 +95,15 @@ from .signals import USER_RETIRE_LMS_CRITICAL, USER_RETIRE_LMS_MISC, USER_RETIRE_MAILINGS from .utils import create_retirement_request_and_deactivate_account, username_suffix_generator +# This is a temporary import path while we transition from integrated_channels to channel_integrations +if getattr(settings, 'ENABLE_LEGACY_INTEGRATED_CHANNELS', True): + from integrated_channels.degreed.models import DegreedLearnerDataTransmissionAudit + from integrated_channels.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit +else: + from channel_integrations.degreed2.models import Degreed2LearnerDataTransmissionAudit \ + as DegreedLearnerDataTransmissionAudit + from channel_integrations.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit + log = logging.getLogger(__name__) USER_PROFILE_PII = { diff --git a/openedx/core/djangoapps/user_api/management/commands/create_user_gdpr_testing.py b/openedx/core/djangoapps/user_api/management/commands/create_user_gdpr_testing.py index 2008ce8652d5..e744baa6c7a3 100644 --- a/openedx/core/djangoapps/user_api/management/commands/create_user_gdpr_testing.py +++ b/openedx/core/djangoapps/user_api/management/commands/create_user_gdpr_testing.py @@ -11,6 +11,7 @@ from consent.models import DataSharingConsent from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user +from django.conf import settings from django.core.management.base import BaseCommand from enterprise.models import ( EnterpriseCourseEnrollment, @@ -18,7 +19,6 @@ EnterpriseCustomerUser, PendingEnterpriseCustomerUser ) -from integrated_channels.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit from opaque_keys.edx.keys import CourseKey from pytz import UTC @@ -31,6 +31,12 @@ from ...models import UserOrgTag +# This is a temporary import path while we transition from integrated_channels to channel_integrations +if getattr(settings, 'ENABLE_LEGACY_INTEGRATED_CHANNELS', True): + from integrated_channels.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit +else: + from channel_integrations.sap_success_factors.models import SapSuccessFactorsLearnerDataTransmissionAudit + class Command(BaseCommand): """ diff --git a/openedx/features/enterprise_support/signals.py b/openedx/features/enterprise_support/signals.py index c8122e2102ca..c3ade14081b3 100644 --- a/openedx/features/enterprise_support/signals.py +++ b/openedx/features/enterprise_support/signals.py @@ -10,10 +10,6 @@ from django.db.models.signals import post_save, pre_save from django.dispatch import receiver from enterprise.models import EnterpriseCourseEnrollment, EnterpriseCustomer -from integrated_channels.integrated_channel.tasks import ( - transmit_single_learner_data, - transmit_single_subsection_learner_data -) from slumber.exceptions import HttpClientError from common.djangoapps.student.signals import UNENROLL_DONE @@ -22,6 +18,18 @@ from openedx.features.enterprise_support.tasks import clear_enterprise_customer_data_consent_share_cache from openedx.features.enterprise_support.utils import clear_data_consent_share_cache, is_enterprise_learner +# This is a temporary import path while we transition from integrated_channels to channel_integrations +if getattr(settings, 'ENABLE_LEGACY_INTEGRATED_CHANNELS', True): + from integrated_channels.integrated_channel.tasks import ( + transmit_single_learner_data, + transmit_single_subsection_learner_data + ) +else: + from channel_integrations.integrated_channel.tasks import ( + transmit_single_learner_data, + transmit_single_subsection_learner_data + ) + log = logging.getLogger(__name__) diff --git a/openedx/features/enterprise_support/tests/test_signals.py b/openedx/features/enterprise_support/tests/test_signals.py index 3207aeb024f3..1a1f742f01f5 100644 --- a/openedx/features/enterprise_support/tests/test_signals.py +++ b/openedx/features/enterprise_support/tests/test_signals.py @@ -6,6 +6,7 @@ from unittest.mock import patch import ddt +from django.conf import settings from django.test.utils import override_settings from django.utils.timezone import now from edx_django_utils.cache import TieredCache @@ -196,7 +197,9 @@ def test_handle_enterprise_learner_passing_grade(self): Test to assert transmit_single_learner_data is called when COURSE_GRADE_NOW_PASSED signal is fired """ with patch( - 'integrated_channels.integrated_channel.tasks.transmit_single_learner_data.apply_async', + 'integrated_channels.integrated_channel.tasks.transmit_single_learner_data.apply_async' + if getattr(settings, 'ENABLE_LEGACY_INTEGRATED_CHANNELS', True) else + 'channel_integrations.integrated_channel.tasks.transmit_single_learner_data.apply_async', return_value=None ) as mock_task_apply: course_key = CourseKey.from_string(self.course_id) @@ -218,7 +221,9 @@ def test_handle_enterprise_learner_subsection(self): Test to assert transmit_subsection_learner_data is called when COURSE_ASSESSMENT_GRADE_CHANGED signal is fired. """ with patch( - 'integrated_channels.integrated_channel.tasks.transmit_single_subsection_learner_data.apply_async', + 'integrated_channels.integrated_channel.tasks.transmit_single_subsection_learner_data.apply_async' + if getattr(settings, 'ENABLE_LEGACY_INTEGRATED_CHANNELS', True) else + 'channel_integrations.integrated_channel.tasks.transmit_single_subsection_learner_data.apply_async', return_value=None ) as mock_task_apply: course_key = CourseKey.from_string(self.course_id)