Skip to content

Commit

Permalink
more logs for data sharing consent
Browse files Browse the repository at this point in the history
ENT-3494
  • Loading branch information
muhammad-ammar committed Nov 2, 2020
1 parent dbe96cf commit 5f04fd3
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions openedx/features/enterprise_support/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ def consent_required(self, enrollment_exists=False, **kwargs):
# Call the endpoint with the given kwargs, and check the value that it provides.
response = self.consent_endpoint.get(**kwargs)

LOGGER.info(
'[ENTERPRISE DSC] Consent Requirement Info. APIParams: [%s], APIResponse: [%s], EnrollmentExists: [%s]',
kwargs,
response,
enrollment_exists,
)

# 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(
'[ENTERPRISE DSC] No Consent Required. APIParams: [%s], APIResponse: [%s], EnrollmentExists: [%s]',
kwargs,
response,
enrollment_exists,
)
return False

# In all other cases, just trust the Consent API.
Expand Down Expand Up @@ -584,6 +585,27 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
for learner in enterprise_learner_details
)

if not consent_needed:
for learner in enterprise_learner_details:
if current_enterprise_uuid != learner['enterprise_customer']['uuid']:
LOGGER.info(
'[ENTERPRISE DSC] Consent requirement failed due to enterprise mismatch. '
'USER: [%s], CurrentEnterprise: [%s], LearnerEnterprise: [%s]',
user.username,
current_enterprise_uuid,
learner['enterprise_customer']['uuid']
)

learner_enterprise_site = Site.objects.get(domain=learner['enterprise_customer']['site']['domain'])
if learner_enterprise_site != request.site:
LOGGER.info(
'[ENTERPRISE DSC] Consent requirement failed due to site mismatch. '
'USER: [%s], RequestSite: [%s], LearnerEnterpriseSite: [%s]',
user.username,
request.site,
learner_enterprise_site
)

if consent_needed:
LOGGER.info(
u"Consent from user [{username}] is needed for course [{course_id}]. The user's current enterprise"
Expand All @@ -594,7 +616,7 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
)
else:
LOGGER.info(
u"Consent from user [{username}] is not needed for course [{course_id}]. The user's current enterprise"
u"Consent from user [{username}] is not needed for course [{course_id}]. The user's current enterprise "
u"does not require data sharing consent.".format(
username=user.username,
course_id=course_id
Expand Down

0 comments on commit 5f04fd3

Please sign in to comment.