Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide logo URL from the backend #25994

Merged
merged 3 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lms/djangoapps/branding/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

"""


import logging

import six
Expand Down Expand Up @@ -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
5 changes: 2 additions & 3 deletions lms/djangoapps/bulk_email/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
to a course.
"""


import json
import logging
import random
Expand Down Expand Up @@ -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
Expand All @@ -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 = (
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 4 additions & 5 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Many of these GETs may become PUTs in the future.
"""


import csv
import json
import logging
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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(
Expand Down
5 changes: 2 additions & 3 deletions openedx/core/djangoapps/ace_common/template_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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(),
}