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

Code before:
    )
    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):
    """
    Retrives the color-scheme of the active theme for current user.
    """
    user = context["request"].user
    # print('userdwa',user)
    # user.wagtail_userprofile.theme = "light"
    theme_name = (
        user.wagtail_userprofile.theme
        if hasattr(user, "wagtail_userprofile")
        else "light"
    )

    # print("themename:",theme_name)
    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.

Review comment (suggestion):
```suggestion
        getattr(user, "wagtail_userprofile", None)
```

We should be able to streamline this, try this out, removing the else block. Then below we would reverse the check, checking for dark first. Meaning we don't need to declare light twice. 

Code after:
    )
    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):
    """
    Wrapper for Django's static file finder to append a cache-busting query parameter
    that updates on each Wagtail version