diff --git a/lms/djangoapps/branding/api.py b/lms/djangoapps/branding/api.py index 4f4ade9abcc..01e240d5dcd 100644 --- a/lms/djangoapps/branding/api.py +++ b/lms/djangoapps/branding/api.py @@ -13,7 +13,6 @@ """ - import logging import six @@ -673,3 +672,11 @@ def get_home_url(): Return Dashboard page url """ return reverse('dashboard') + + +def get_logo_url_for_email(): + """ + Returns the url for the branded logo image for embedding in email templates. + """ + default_logo_url = getattr(settings, 'DEFAULT_EMAIL_LOGO_URL', None) + return getattr(settings, 'LOGO_URL_PNG', None) or default_logo_url diff --git a/lms/djangoapps/bulk_email/tasks.py b/lms/djangoapps/bulk_email/tasks.py index 65665f2289e..05a2b4fdd66 100644 --- a/lms/djangoapps/bulk_email/tasks.py +++ b/lms/djangoapps/bulk_email/tasks.py @@ -4,7 +4,6 @@ to a course. """ - import json import logging import random @@ -41,6 +40,7 @@ from markupsafe import escape from six import text_type +from lms.djangoapps.branding.api import get_logo_url_for_email from lms.djangoapps.bulk_email.models import CourseEmail, Optout from lms.djangoapps.bulk_email.api import get_unsubscribed_link from lms.djangoapps.courseware.courses import get_course @@ -58,7 +58,6 @@ log = logging.getLogger('edx.celery.task') - # Errors that an individual email is failing to be sent, and should just # be treated as a fail. SINGLE_EMAIL_FAILURE_ERRORS = ( @@ -123,6 +122,7 @@ def _get_course_email_context(course): 'course_end_date': course_end_date, 'account_settings_url': '{}{}'.format(lms_root_url, reverse('account_settings')), 'email_settings_url': '{}{}'.format(lms_root_url, reverse('dashboard')), + 'logo_url': get_logo_url_for_email(), 'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME), 'year': timezone.now().year, } @@ -294,7 +294,6 @@ def send_course_email(entry_id, email_id, to_list, global_email_context, subtask send_exception = None new_subtask_status = None try: - course_title = global_email_context['course_title'] start_time = time.time() new_subtask_status, send_exception = _send_course_email( entry_id, diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index 0c2b227af7a..3cf21cd0d8f 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -6,7 +6,6 @@ Many of these GETs may become PUTs in the future. """ - import csv import json import logging @@ -315,8 +314,8 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man """ if not configuration_helpers.get_value( - 'ALLOW_AUTOMATED_SIGNUPS', - settings.FEATURES.get('ALLOW_AUTOMATED_SIGNUPS', False), + 'ALLOW_AUTOMATED_SIGNUPS', + settings.FEATURES.get('ALLOW_AUTOMATED_SIGNUPS', False), ): return HttpResponseForbidden() @@ -2959,8 +2958,8 @@ def invalidate_certificate(request, generated_certificate, certificate_invalidat :return: dict object containing updated certificate invalidation data. """ if CertificateInvalidation.get_certificate_invalidations( - generated_certificate.course_id, - generated_certificate.user, + generated_certificate.course_id, + generated_certificate.user, ): raise ValueError( _(u"Certificate of {user} has already been invalidated. Please check your spelling and retry.").format( diff --git a/openedx/core/djangoapps/ace_common/template_context.py b/openedx/core/djangoapps/ace_common/template_context.py index a1339e209f5..303bfcc204c 100644 --- a/openedx/core/djangoapps/ace_common/template_context.py +++ b/openedx/core/djangoapps/ace_common/template_context.py @@ -2,10 +2,10 @@ Context dictionary for templates that use the ace_common base template. """ - from django.conf import settings from django.urls import NoReverseMatch, reverse +from lms.djangoapps.branding.api import get_logo_url_for_email from common.djangoapps.edxmako.shortcuts import marketing_link from openedx.core.djangoapps.theming.helpers import get_config_value_from_site_or_settings @@ -16,7 +16,6 @@ def get_base_template_context(site): """ # When on LMS and a dashboard is available, use that as the dashboard url. # Otherwise, use the home url instead. - default_logo_url = getattr(settings, 'DEFAULT_EMAIL_LOGO_URL') try: dashboard_url = reverse('dashboard') except NoReverseMatch: @@ -38,5 +37,5 @@ def get_base_template_context(site): 'CONTACT_MAILING_ADDRESS', site=site, site_config_name='contact_mailing_address'), 'social_media_urls': get_config_value_from_site_or_settings('SOCIAL_MEDIA_FOOTER_URLS', site=site), 'mobile_store_urls': get_config_value_from_site_or_settings('MOBILE_STORE_URLS', site=site), - 'logo_url': getattr(settings, 'LOGO_URL_PNG', default_logo_url), + 'logo_url': get_logo_url_for_email(), }