Repository: wagtail/wagtail
File: wagtail/admin/templatetags/wagtailadmin_tags.py (Python)

Code before:
        user.wagtail_userprofile.theme
        if hasattr(user, "wagtail_userprofile")
        else "system"
    )
    contrast_name = (
        user.wagtail_userprofile.contrast
        if hasattr(user, "wagtail_userprofile")
        else "system"
    )
    density_name = (
        user.wagtail_userprofile.density
        if hasattr(user, "wagtail_userprofile")
        else "default"
    )
    contrast_name = contrast_name.split("_")[0]
    return f"w-theme-{theme_name} w-density-{density_name} w-contrast-{contrast_name}"


@register.simple_tag(takes_context=True)
def admin_theme_color_scheme(context):
    """
    Retrieves the color-scheme of the active theme for current user.
    """
    user = context["request"].user
    theme_name = getattr(user, "wagtail_userprofile", None)
    theme_name = theme_name.theme if theme_name else "light"
    if theme_name == "light":
        return "light dark"

    else:
        return "dark light"


@register.simple_tag
def js_translation_strings():
    warn(
        "The `js_translation_strings` template tag will be removed in a future release.",
        category=RemovedInWagtail70Warning,
    )
    return mark_safe(json.dumps(get_js_translation_strings()))


@register.simple_tag
def notification_static(path):
    """
    Variant of the {% static %}` tag for use in notification emails - tries to form
    a full URL using WAGTAILADMIN_BASE_URL if the static URL isn't already a full URL.
    """
    return urljoin(base_url_setting(), static(path))



Review comment (suggestion):
It's not correct to store the UserProfile object in a `theme_name` variable, because it's not the theme name.

```suggestion
    profile = getattr(user, "wagtail_userprofile", None)
    theme_name = profile.theme if profile else "system"
```

Code after:
        user.wagtail_userprofile.theme
        if hasattr(user, "wagtail_userprofile")
        else "system"
    )
    contrast_name = (
        user.wagtail_userprofile.contrast
        if hasattr(user, "wagtail_userprofile")
        else "system"
    )
    density_name = (
        user.wagtail_userprofile.density
        if hasattr(user, "wagtail_userprofile")
        else "default"
    )
    contrast_name = contrast_name.split("_")[0]
    return f"w-theme-{theme_name} w-density-{density_name} w-contrast-{contrast_name}"


@register.simple_tag(takes_context=True)
def admin_theme_color_scheme(context):
    """
    Retrieves the color-scheme of the active theme for current user.
    """
    user = context["request"].user
    profile = getattr(user, "wagtail_userprofile", None)
    theme_name = profile.theme if profile else "system"
    if theme_name == "system":
        return "dark light"
    return theme_name


@register.simple_tag
def js_translation_strings():
    warn(
        "The `js_translation_strings` template tag will be removed in a future release.",
        category=RemovedInWagtail70Warning,
    )
    return mark_safe(json.dumps(get_js_translation_strings()))


@register.simple_tag
def notification_static(path):
    """
    Variant of the {% static %}` tag for use in notification emails - tries to form
    a full URL using WAGTAILADMIN_BASE_URL if the static URL isn't already a full URL.
    """
    return urljoin(base_url_setting(), static(path))


@register.simple_tag
def versioned_static(path):