Coverage for app/venv/lib/python3.14/site-packages/weblate/wladmin/templatetags/check_links.py: 57%

17 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 07:15 +0000

1# Copyright © Michal Čihař <michal@weblate.org> 

2# 

3# SPDX-License-Identifier: GPL-3.0-or-later 

4 

5from __future__ import annotations 

6 

7from typing import TYPE_CHECKING, cast 

8 

9from django import template 

10 

11from weblate.trans.templatetags.translations import render_documentation_icon 

12from weblate.utils.checks import check_doc_link 

13 

14if TYPE_CHECKING: 14 ↛ 15line 14 didn't jump to line 15 because the condition on line 14 was never true

15 from django.core.checks import CheckMessage 

16 

17register = template.Library() 

18 

19 

20@register.simple_tag 

21def check_link(check: CheckMessage) -> str: 

22 fallback = None 

23 if check.hint and check.hint.startswith("https:"): 

24 fallback = check.hint 

25 return configuration_error_link(cast("str", check.id), fallback=fallback) 

26 

27 

28@register.simple_tag 

29def configuration_error_link(check: str, fallback: str | None = None) -> str: 

30 return render_documentation_icon(check_doc_link(check) or fallback)