Provide logo URL from the backend

This commit is contained in:
Awais Jibran
2021-01-06 17:30:13 +05:00
parent 3626c3b91f
commit 7e20cf2215
3 changed files with 12 additions and 4 deletions

View File

@@ -13,7 +13,6 @@ the marketing site and blog).
"""
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')
return getattr(settings, 'LOGO_URL_PNG') or default_logo_url

View File

@@ -41,6 +41,7 @@ from edx_django_utils.monitoring import set_code_owner_attribute
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
@@ -123,6 +124,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 +296,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,

View File

@@ -6,6 +6,7 @@ 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 +17,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 +38,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(),
}