diff --git a/course/templates/course/_course_menu.html b/course/templates/course/_course_menu.html index 6857390b3..9b5d9b2c2 100644 --- a/course/templates/course/_course_menu.html +++ b/course/templates/course/_course_menu.html @@ -110,7 +110,8 @@

{{ group.label|parse_localization }}

{% for entry in group.items %} {% if entry.enabled %}
  • - + {% is_external_menu_url entry.url as is_external_menu_url_flag %} + {% if entry.icon_class %} {% endif %} diff --git a/course/templatetags/course.py b/course/templatetags/course.py index 991c8f2fc..b032c6679 100644 --- a/course/templatetags/course.py +++ b/course/templatetags/course.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Union +from typing import Any, Dict, List, Optional, Union from django import template from django.db import models @@ -139,6 +139,13 @@ def tags(profile, instance): return mark_safe(' '.join(tag.html_label for tag in tags)) +@register.simple_tag +def is_external_menu_url(url: Optional[str]) -> bool: + if url and '://' in url: + return True + return False + + @register.filter def enrollment_audience(enrollment_audience_val): # convert enrollment audience Enum value to the string description diff --git a/external_services/models.py b/external_services/models.py index 02f7a66d4..429ec148c 100644 --- a/external_services/models.py +++ b/external_services/models.py @@ -335,7 +335,6 @@ def url(self): } return self.service.as_leaf_class().get_url(replace=self.menu_url, kwargs=kwargs) if '://' in self.menu_url: - # Deprecated, but DB can have old urls return self.menu_url return urljoin(self.course_instance.get_absolute_url(), self.menu_url)