Commit 10e9fed6 by Matt Drayer

Pass required values via context to invalid template

parent 76bc375f
......@@ -241,13 +241,21 @@ def render_html_view(request):
This view generates an HTML representation of the specified student's certificate
If a certificate is not available, we display a "Sorry!" screen instead
"""
# Initialize the template context and bootstrap with default values from configuration
context = {}
configuration = CertificateHtmlViewConfiguration.get_config()
context = configuration.get('default', {})
invalid_template_path = 'certificates/invalid.html'
# Translators: This text is bound to the HTML 'title' element of the page and appears
# in the browser title bar when a requested certificate is not found or recognized
context['document_title'] = _("Invalid Certificate")
# Feature Flag check
if not settings.FEATURES.get('CERTIFICATES_HTML_VIEW', False):
return render_to_response(invalid_template_path)
return render_to_response(invalid_template_path, context)
context = {}
course_id = request.GET.get('course', None)
context['course'] = course_id
if not course_id:
......@@ -271,9 +279,6 @@ def render_html_view(request):
except GeneratedCertificate.DoesNotExist:
return render_to_response(invalid_template_path, context)
# Load static output values from configuration,
configuration = CertificateHtmlViewConfiguration.get_config()
context = configuration.get('default', {})
# Override the defaults with any mode-specific static values
context.update(configuration.get(certificate.mode, {}))
# Override further with any course-specific static values
......
......@@ -6,6 +6,7 @@
# set doc language direction
from django.utils.translation import get_language_bidi
dir_rtl = 'rtl' if get_language_bidi() else 'ltr'
document_body_class = document_body_class_append if document_body_class_append else ''
%>
<!DOCTYPE html>
......@@ -20,7 +21,7 @@
<%include file="_assets-primary.html" />
</head>
<body class="view-certificate view-valid-certificate ${dir_rtl} ${document_body_class_append}" data-view="valid-certificate">
<body class="view-certificate view-valid-certificate ${dir_rtl} ${document_body_class}" data-view="valid-certificate">
<div class="wrapper-view">
${self.body()}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment