fix: dynamically generated unverified cert data (#30365)

This commit is contained in:
Cristhian Garcia
2022-06-03 10:46:46 -05:00
committed by GitHub
parent 142945c930
commit e66036bba2

View File

@@ -203,18 +203,6 @@ REQUESTING_CERT_DATA = CertData(
certificate_available_date=None
)
UNVERIFIED_CERT_DATA = CertData(
CertificateStatuses.unverified,
_('Certificate unavailable'),
_(
'You have not received a certificate because you do not have a current {platform_name} '
'verified identity.'
).format(platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)),
download_url=None,
cert_web_view_url=None,
certificate_available_date=None
)
def _earned_but_not_available_cert_data(cert_downloadable_status):
return CertData(
@@ -238,6 +226,23 @@ def _downloadable_cert_data(download_url=None, cert_web_view_url=None):
)
def _unverified_cert_data():
"""
platform_name is dynamically updated in multi-tenant installations
"""
return CertData(
CertificateStatuses.unverified,
_('Certificate unavailable'),
_(
'You have not received a certificate because you do not have a current {platform_name} '
'verified identity.'
).format(platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)),
download_url=None,
cert_web_view_url=None,
certificate_available_date=None
)
def user_groups(user):
"""
TODO (vshnayder): This is not used. When we have a new plan for groups, adjust appropriately.
@@ -1196,15 +1201,12 @@ def _certificate_message(student, course, enrollment_mode): # lint-amnesty, pyl
if cert_downloadable_status['is_generating']:
return GENERATING_CERT_DATA
if cert_downloadable_status['is_unverified']:
return UNVERIFIED_CERT_DATA
if cert_downloadable_status['is_unverified'] or _missing_required_verification(student, enrollment_mode):
return _unverified_cert_data()
if cert_downloadable_status['is_downloadable']:
return _downloadable_certificate_message(course, cert_downloadable_status)
if _missing_required_verification(student, enrollment_mode):
return UNVERIFIED_CERT_DATA
return REQUESTING_CERT_DATA