chore: refine source param in dsc url
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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}']
|
||||
|
||||
Reference in New Issue
Block a user