Coverage for quality/templatetags/quality_extras.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-26 15:42 +0000

1from django import template 

2from django.http.request import QueryDict 

3 

4from quality.models import Check 

5 

6register = template.Library() 

7 

8RESULT_COLORS = { 

9 Check.Result.NO_DATA: "danger", 

10 Check.Result.NOT_READABLE: "danger", 

11 Check.Result.DECONVOLUTION_FAILS: "warning", 

12 Check.Result.DECONVOLUTION_PASS: "success", 

13 Check.Result.CHANNEL_CLOSED: "dark", 

14} 

15 

16 

17@register.filter 

18def colorize(value: Check.Result) -> str: 

19 """ 

20 Colorizes the result of a check 

21 """ 

22 return RESULT_COLORS[value] 

23 

24 

25@register.filter 

26def getlist(query_dict: QueryDict, key: str) -> list[str]: 

27 """ 

28 Returns a list of the data with the requested key. 

29 Returns an empty list if the key doesn't exist. 

30 """ 

31 return query_dict.getlist(key)