Fix visible dates sent to Credentials

If we have a future available_date, send that to Credentials rather
than sending the modified date.

LEARNER-5995
This commit is contained in:
Michael Terry
2018-07-31 16:29:59 -04:00
committed by Diana Huang
parent d9e841298d
commit caaf351e63
4 changed files with 61 additions and 11 deletions

View File

@@ -12,7 +12,7 @@ from opaque_keys.edx.keys import CourseKey
from course_modes.models import CourseMode
from lms.djangoapps.certificates.models import GeneratedCertificate
from openedx.core.djangoapps.certificates.api import display_date_for_certificate
from openedx.core.djangoapps.certificates.api import available_date_for_certificate
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.credentials.models import CredentialsApiConfig
from openedx.core.djangoapps.credentials.utils import get_credentials, get_credentials_api_client
@@ -301,7 +301,7 @@ def award_course_certificate(self, username, course_run_key):
# FIXME This may result in visible dates that do not update alongside the Course Overview if that changes
# This is a known limitation of this implementation and was chosen to reduce the amount of replication,
# endpoints, celery tasks, and jenkins jobs that needed to be written for this functionality
visible_date = display_date_for_certificate(course_overview, certificate)
visible_date = available_date_for_certificate(course_overview, certificate)
post_course_certificate(credentials_client, username, certificate, visible_date)
LOGGER.info('Awarded certificate for course %s to user %s', course_key, username)

View File

@@ -414,8 +414,10 @@ class AwardCourseCertificatesTestCase(CredentialsApiConfigMixin, TestCase):
def setUp(self):
super(AwardCourseCertificatesTestCase, self).setUp()
self.available_date = datetime.datetime.max
self.course = CourseOverviewFactory.create(
self_paced=True # Any option to allow the certificate to be viewable for the course
self_paced=True, # Any option to allow the certificate to be viewable for the course
certificate_available_date=self.available_date,
)
self.student = UserFactory.create(username='test-student')
# Instantiate the Certificate first so that the config doesn't execute issuance
@@ -440,6 +442,7 @@ class AwardCourseCertificatesTestCase(CredentialsApiConfigMixin, TestCase):
call_args, _ = mock_post_course_certificate.call_args
self.assertEqual(call_args[1], self.student.username)
self.assertEqual(call_args[2], self.certificate)
self.assertEqual(call_args[3], self.available_date)
def test_award_course_cert_not_called_if_disabled(self, mock_post_course_certificate):
"""