From 803a73fdad47617871777b3cd0d439ee34e5d0ca Mon Sep 17 00:00:00 2001 From: Matt Drayer Date: Thu, 4 Jun 2015 13:22:25 -0400 Subject: [PATCH] mattdrayer/SOL-953: Remove Mako UNDEFINED overrides --- .../certificates/tests/factories.py | 1 + .../certificates/tests/test_views.py | 3 +- lms/djangoapps/certificates/views.py | 36 +++++++++++-------- .../certificates/_accomplishment-banner.html | 4 ++- .../_accomplishment-rendering.html | 2 +- .../certificates/accomplishment-base.html | 4 +-- lms/templates/certificates/invalid.html | 5 +-- lms/templates/certificates/valid.html | 6 ++-- 8 files changed, 32 insertions(+), 29 deletions(-) diff --git a/lms/djangoapps/certificates/tests/factories.py b/lms/djangoapps/certificates/tests/factories.py index b22fe0c8eb..aac6b2d5cc 100644 --- a/lms/djangoapps/certificates/tests/factories.py +++ b/lms/djangoapps/certificates/tests/factories.py @@ -51,6 +51,7 @@ class CertificateHtmlViewConfigurationFactory(DjangoModelFactory): "default": { "accomplishment_class_append": "accomplishment-certificate", "platform_name": "edX", + "company_about_url": "http://www.edx.org/about-us", "company_privacy_url": "http://www.edx.org/edx-privacy-policy", "company_tos_url": "http://www.edx.org/edx-terms-service", "company_verified_certificate_url": "http://www.edx.org/verified-certificate", diff --git a/lms/djangoapps/certificates/tests/test_views.py b/lms/djangoapps/certificates/tests/test_views.py index 7e7e55c822..c00938c075 100644 --- a/lms/djangoapps/certificates/tests/test_views.py +++ b/lms/djangoapps/certificates/tests/test_views.py @@ -180,7 +180,7 @@ class UpdateExampleCertificateViewTest(TestCase): @attr('shard_1') class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase): """ - Tests for the manual refund page + Tests for the certificates web/html views """ def setUp(self): super(CertificatesViewsTests, self).setUp() @@ -421,6 +421,7 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase): response = self.client.get(test_url) self.assertIn("Invalid Certificate", response.content) + @override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED) def test_evidence_event_sent(self): test_url = get_certificate_url(user_id=self.user.id, course_id=self.course_id) + '?evidence_visit=1' self.recreate_tracker() diff --git a/lms/djangoapps/certificates/views.py b/lms/djangoapps/certificates/views.py index 31234570eb..162611c103 100644 --- a/lms/djangoapps/certificates/views.py +++ b/lms/djangoapps/certificates/views.py @@ -295,7 +295,6 @@ def _update_certificate_context(context, course, user, user_certificate): context['accomplishment_copy_username'] = user.username context['accomplishment_copy_course_org'] = course.org context['accomplishment_copy_course_name'] = course.display_name - context['logo_alt'] = platform_name try: badge = BadgeAssertion.objects.get(user=user, course_id=course.location.course_key) except BadgeAssertion.DoesNotExist: @@ -389,23 +388,11 @@ def _update_certificate_context(context, course, user, user_certificate): context['company_contact_urltext'] = _("Contact {platform_name}").format(platform_name=platform_name) - context['company_privacy_urltext'] = _("Privacy Policy") - - context['company_tos_urltext'] = _("Terms of Service & Honor Code") - # Translators: This text appears near the top of the certficate and describes the guarantee provided by edX context['document_banner'] = _("{platform_name} acknowledges the following student accomplishment").format( platform_name=platform_name ) - context['logo_subtitle'] = _("Certificate Validation") - - # Translators: This is the copyright line which appears at the bottom of the certificate page/screen - context['copyright_text'] = _('© {year} {platform_name}. All rights reserved.').format( - year=datetime.now().year, - platform_name=platform_name - ) - # Translators: This text represents the verification of the certificate context['document_meta_description'] = _('This is a valid {platform_name} certificate for {user_name}, ' 'who participated in {partner_name} {course_number}').format( @@ -472,7 +459,7 @@ def render_html_view(request, user_id, course_id): If a certificate is not available, we display a "Sorry!" screen instead """ - # Create the view context and bootstrap with Django settings and passed-in values + # Create the initial view context, bootstrapping with Django settings and passed-in values context = {} context['platform_name'] = settings.PLATFORM_NAME context['course_id'] = course_id @@ -481,9 +468,27 @@ def render_html_view(request, user_id, course_id): configuration = CertificateHtmlViewConfiguration.get_config() context.update(configuration.get('default', {})) + # Translators: 'All rights reserved' is a legal term used in copyrighting to protect published content + reserved = _("All rights reserved") + context['copyright_text'] = '© {year} {platform_name}. {reserved}.'.format( + year=settings.COPYRIGHT_YEAR, + platform_name=settings.PLATFORM_NAME, + reserved=reserved + ) + # 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") + + # Translators: The & characters represent an ampersand character and can be ignored + context['company_tos_urltext'] = _("Terms of Service & Honor Code") + + # Translators: A 'Privacy Policy' is a legal document/statement describing a website's use of personal information + context['company_privacy_urltext'] = _("Privacy Policy") + + # Translators: This line appears as a byline to a header image and describes the purpose of the page + context['logo_subtitle'] = _("Certificate Validation") + context['logo_alt'] = settings.PLATFORM_NAME invalid_template_path = 'certificates/invalid.html' # Kick the user back to the "Invalid" screen if the feature is disabled @@ -521,8 +526,8 @@ def render_html_view(request, user_id, course_id): except (InvalidKeyError, CourseDoesNotExist, User.DoesNotExist): return render_to_response(invalid_template_path, context) + # Badge Request Event Tracking Logic if 'evidence_visit' in request.GET: - print "Event request found!" try: badge = BadgeAssertion.objects.get(user=user, course_id=course_key) tracker.emit( @@ -566,6 +571,7 @@ def render_html_view(request, user_id, course_id): # Override further with any course-specific static values context.update(course.cert_html_view_overrides) + # FINALLY, generate and send the output the client return render_to_response("certificates/valid.html", context) diff --git a/lms/templates/certificates/_accomplishment-banner.html b/lms/templates/certificates/_accomplishment-banner.html index 6fab797192..35daef51db 100644 --- a/lms/templates/certificates/_accomplishment-banner.html +++ b/lms/templates/certificates/_accomplishment-banner.html @@ -20,14 +20,16 @@ ${_("Print Certificate")} + %if linked_in_url: + data-certificate-mode="${course_mode}"> ${_('Share on LinkedIn')} + %endif diff --git a/lms/templates/certificates/_accomplishment-rendering.html b/lms/templates/certificates/_accomplishment-rendering.html index bc2367f367..ac7597cb35 100644 --- a/lms/templates/certificates/_accomplishment-rendering.html +++ b/lms/templates/certificates/_accomplishment-rendering.html @@ -21,7 +21,7 @@ course_mode_class = course_mode if course_mode else '' - ${certificate_title} + ${document_title}
diff --git a/lms/templates/certificates/accomplishment-base.html b/lms/templates/certificates/accomplishment-base.html index 44ece70951..5c3c9f4741 100644 --- a/lms/templates/certificates/accomplishment-base.html +++ b/lms/templates/certificates/accomplishment-base.html @@ -1,7 +1,5 @@ -<%! from django.utils.translation import ugettext as _ %> -<%! import mako.runtime %> -<% mako.runtime.UNDEFINED = '' %> <%namespace name='static' file='/static_content.html'/> +<%! from django.utils.translation import ugettext as _ %> <% # set doc language direction diff --git a/lms/templates/certificates/invalid.html b/lms/templates/certificates/invalid.html index 59b238446c..840ad01e31 100644 --- a/lms/templates/certificates/invalid.html +++ b/lms/templates/certificates/invalid.html @@ -1,8 +1,5 @@ -<%! from django.utils.translation import ugettext as _ %> -<%! import mako.runtime %> -<% mako.runtime.UNDEFINED = '' %> - <%inherit file="accomplishment-base.html" /> +<%! from django.utils.translation import ugettext as _ %>
diff --git a/lms/templates/certificates/valid.html b/lms/templates/certificates/valid.html index 881982739c..f287a3e1ab 100644 --- a/lms/templates/certificates/valid.html +++ b/lms/templates/certificates/valid.html @@ -1,8 +1,6 @@ -<%! from django.utils.translation import ugettext as _ %> -<%! import mako.runtime %> -<% mako.runtime.UNDEFINED = '' %> - <%inherit file="accomplishment-base.html" /> +<%! from django.utils.translation import ugettext as _ %> + % if user.is_authenticated() and user.id == int(accomplishment_user_id): <%include file="_accomplishment-banner.html" /> % endif