chore: refine source param in dsc url

This commit is contained in:
muhammad-ammar
2022-06-16 19:13:08 +05:00
parent 9762ccf5cd
commit dd70066644
3 changed files with 6 additions and 5 deletions

View File

@@ -81,7 +81,7 @@ class WikiAccessMiddleware(MiddlewareMixin):
return redirect('about_course', str(course_id))
# If we need enterprise data sharing consent for this course, then redirect to the form.
consent_url = get_enterprise_consent_url(request, str(course_id))
consent_url = get_enterprise_consent_url(request, str(course_id), source='WikiAccessMiddleware')
if consent_url:
return redirect(consent_url)

View File

@@ -352,7 +352,8 @@ def data_sharing_consent_required(view_func):
Otherwise, just call the wrapped view function.
"""
# Redirect to the consent URL, if consent is required.
consent_url = get_enterprise_consent_url(request, course_id, enrollment_exists=True)
source = getattr(view_func, '__name__', '')
consent_url = get_enterprise_consent_url(request, course_id, enrollment_exists=True, source=source)
if consent_url:
real_user = getattr(request.user, 'real_user', request.user)
LOGGER.info(
@@ -721,7 +722,7 @@ def get_consent_required_courses(user, course_ids):
@enterprise_is_enabled(otherwise='')
def get_enterprise_consent_url(request, course_id, user=None, return_to=None, enrollment_exists=False):
def get_enterprise_consent_url(request, course_id, user=None, return_to=None, enrollment_exists=False, source='lms'):
"""
Build a URL to redirect the user to the Enterprise app to provide data sharing
consent for a specific course ID.
@@ -753,7 +754,7 @@ def get_enterprise_consent_url(request, course_id, user=None, return_to=None, en
url_params = {
'enterprise_customer_uuid': enterprise_customer_uuid_for_request(request),
'course_id': course_id,
'source': 'lms-courseware',
'source': source,
'next': request.build_absolute_uri(return_path),
'failure_url': request.build_absolute_uri(
reverse('dashboard') + '?' + urlencode(

View File

@@ -712,7 +712,7 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
expected_path = '/courses/course-v1:edX+DemoX+Demo_Course/courseware'
expected_url_args = {
'course_id': ['course-v1:edX+DemoX+Demo_Course'],
'source': ['lms-courseware'],
'source': ['lms'],
'failure_url': ['http://localhost:8000/dashboard?consent_failed=course-v1%3AedX%2BDemoX%2BDemo_Course'],
'enterprise_customer_uuid': ['cf246b88-d5f6-4908-a522-fc307e0b0c59'],
'next': [f'http://localhost:8000{expected_path}']