Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Unreleased
----------
* nothing unreleased

[8.10.0] - 2026-09-08
----------------------
* feat: add SupportContactEnterpriseTagStep pipeline step (ENT-11574)

[8.9.4] - 2026-08-27
---------------------
* fix: add Django admin helper text for ``enable_demo_data_for_analytics_and_lpr`` explaining that
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "8.9.4"
__version__ = "8.10.0"
32 changes: 32 additions & 0 deletions enterprise/filters/support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Pipeline steps for the support views filters.
"""
from crum import get_current_request
from openedx_filters.filters import PipelineStep

# This import will be replaced with an internal path in ENT-11576 when
# enterprise_support is migrated into edx-enterprise.
try:
from openedx.features.enterprise_support.api import enterprise_customer_for_request
except ImportError:
enterprise_customer_for_request = None


class SupportContactEnterpriseTagStep(PipelineStep):
"""
Append a support-ticket tag for linked customer-account requests.

This step is intended to be registered as a pipeline step for the
``org.openedx.learning.support.contact.context.requested.v1`` filter.
"""

def run_filter(self, tags, user): # pylint: disable=arguments-differ
"""
Append 'enterprise_learner' to tags if the requester is linked to a customer account.
"""
request = get_current_request()
customer = enterprise_customer_for_request(request)
Comment thread
pwnage101 marked this conversation as resolved.
if customer and 'enterprise_learner' not in tags:
tags = [*tags, 'enterprise_learner']

return {'tags': tags, 'user': user}
4 changes: 4 additions & 0 deletions enterprise/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"fail_silently": False,
"pipeline": ["enterprise.filters.course_modes.CalculateEnterpriseDiscountedPrice"],
},
"org.openedx.learning.support.contact.context.requested.v1": {
"fail_silently": False,
"pipeline": ["enterprise.filters.support.SupportContactEnterpriseTagStep"],
},
# NOTE: Pipeline ordering matters here. ActiveEnterpriseCheckStep must run before
# consent's DataSharingConsentCourseAccessStep to match the original platform behavior
# (the incorrect-enterprise redirect took priority over the DSC redirect). This ordering
Expand Down
75 changes: 75 additions & 0 deletions tests/filters/test_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
Tests for enterprise.filters.support pipeline steps.
"""
from unittest.mock import patch

from django.test import RequestFactory, TestCase

from enterprise.filters.support import SupportContactEnterpriseTagStep
from test_utils.factories import UserFactory

CONTACT_FILTER_TYPE = "org.openedx.learning.support.contact.context.requested.v1"


class TestSupportContactEnterpriseTagStep(TestCase):
"""
Tests for SupportContactEnterpriseTagStep pipeline step.
"""

def _make_step(self):
return SupportContactEnterpriseTagStep(CONTACT_FILTER_TYPE, [])

def _make_request(self):
return RequestFactory().get('/')

@patch('enterprise.filters.support.enterprise_customer_for_request')
@patch('enterprise.filters.support.get_current_request')
def test_appends_tag_for_linked_customer_request(self, mock_get_current_request, mock_customer_for_request):
"""
When the request is associated with a linked customer account, 'enterprise_learner'
is appended to the tags list.
"""
mock_customer_for_request.return_value = {'uuid': 'some-uuid', 'name': 'Test Customer'}
request = self._make_request()
mock_get_current_request.return_value = request
user = UserFactory()
tags = ['some_tag']

step = self._make_step()
result = step.run_filter(tags=tags, user=user)

assert result['tags'] == ['some_tag', 'enterprise_learner']
assert result['user'] is user
mock_customer_for_request.assert_called_once_with(request)

@patch('enterprise.filters.support.enterprise_customer_for_request')
@patch('enterprise.filters.support.get_current_request')
def test_does_not_duplicate_tag(self, mock_get_current_request, mock_customer_for_request):
"""
When 'enterprise_learner' is already in the tags list, it is not duplicated.
"""
mock_customer_for_request.return_value = {'uuid': 'some-uuid', 'name': 'Test Customer'}
mock_get_current_request.return_value = self._make_request()
user = UserFactory()
tags = ['enterprise_learner']

step = self._make_step()
result = step.run_filter(tags=tags, user=user)

assert result['tags'].count('enterprise_learner') == 1

@patch('enterprise.filters.support.enterprise_customer_for_request')
@patch('enterprise.filters.support.get_current_request')
def test_does_not_append_tag_for_unlinked_request(self, mock_get_current_request, mock_customer_for_request):
"""
When the request is not associated with a linked customer account, tags are unchanged.
"""
mock_customer_for_request.return_value = None
mock_get_current_request.return_value = self._make_request()
user = UserFactory()
tags = ['some_tag']

step = self._make_step()
result = step.run_filter(tags=tags, user=user)

assert result['tags'] == ['some_tag']