Rolling back previous changes (#25418)

Rolling back previous changes after unexpected behavior
when testing in stage.

ENT-3494
This commit is contained in:
Mike OConnell
2020-10-23 07:09:09 -04:00
committed by GitHub
parent 49ea5f5188
commit 64ee4a8972

View File

@@ -101,35 +101,12 @@ class ConsentApiClient(object):
"""
# Call the endpoint with the given kwargs, and check the value that it provides.
LOGGER.info(
u"Calling enterprise consent API for user [{username}] and course [{course_id}].".format(
username=kwargs.get('username'),
course_id=kwargs.get('course_id')
)
)
response = self.consent_endpoint.get(**kwargs)
# No Enterprise record exists, but we're already enrolled in a course. So, go ahead and proceed.
if enrollment_exists and not response.get('exists', False):
LOGGER.info(
u"No enterprise record exists for user [{username}] and course [{course_id}], but the user is already "
u"enrolled, so consent is not required.".format(
username=kwargs.get('username'),
course_id=kwargs.get('course_id')
)
)
return False
LOGGER.info(
u"The response from the Enterprise API to check if consent is required for user [{username}] and course "
u"[{course_id}] is [{required}]. ".format(
username=kwargs.get('username'),
course_id=kwargs.get('course_id'),
required=response['consent_required']
)
)
# In all other cases, just trust the Consent API.
return response['consent_required']
@@ -576,7 +553,6 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
return False
enterprise_learner_details = get_enterprise_learner_data_from_db(user)
consent_needed = False
if not enterprise_learner_details:
LOGGER.info(
u"Consent from user [{username}] is not needed for course [{course_id}]. The user is not linked to an"
@@ -588,31 +564,18 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
else:
client = ConsentApiClient(user=request.user)
current_enterprise_uuid = enterprise_customer_uuid_for_request(request)
for learner in enterprise_learner_details:
if current_enterprise_uuid != learner['enterprise_customer']['uuid']:
# ignore details for enterprises other than the one the learner is currently logged in as
continue
if Site.objects.get(domain=learner['enterprise_customer']['site']['domain']) != request.site:
LOGGER.info(
u"Consent check for user [{username}] and course [{course_id}] found a site mismatch. The learner "
u"details site [{learner_site}] doesn't match the request site [{request_site}]".format(
username=user.username,
course_id=course_id,
learner_site=learner['enterprise_customer']['site']['domain'],
request_site=request.site
)
)
# ignore details for enterprises whose site doesn't match the request site
continue
if client.consent_required(
consent_needed = any(
current_enterprise_uuid == learner['enterprise_customer']['uuid']
and Site.objects.get(domain=learner['enterprise_customer']['site']['domain']) == request.site
and client.consent_required(
username=user.username,
course_id=course_id,
enterprise_customer_uuid=current_enterprise_uuid,
enrollment_exists=enrollment_exists,
):
# consent is required, no longer necessary to check other details
consent_needed = True
break
)
for learner in enterprise_learner_details
)
if consent_needed:
LOGGER.info(
u"Consent from user [{username}] is needed for course [{course_id}]. The user's current enterprise"