diff options
author | Ali Alnubani <alialnu@mellanox.com> | 2019-01-08 12:38:47 +0000 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2019-02-25 11:11:53 +0000 |
commit | 974ff0c9959db22371907c22c0c0ff5bb079ebf2 (patch) | |
tree | efbf58e2d05a9a71252f5b338f8ad6f16fd9e394 /patchwork/templatetags | |
parent | bc7810e241e27c1c0476145e665da5d156253e1a (diff) | |
download | patchwork-974ff0c9959db22371907c22c0c0ff5bb079ebf2.tar patchwork-974ff0c9959db22371907c22c0c0ff5bb079ebf2.tar.gz |
Beautify check counts in the patch list view
This patch [1] adds colors to the checks in the patch list view.
The colors are set based on the check's priority, with FAILURE
having the highest priority, followed by WARNING, and then SUCCESS.
Only the check with the highest priority and non-zero count
will be colored. This is to make failures and warnings more visible.
The patch also [2] replaces zero counts with a '-' for
FAILUREs and WARNINGs.
The SUCCESS count will only be replaced by a '-'
when all other checks have zero counts too.
Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
Diffstat (limited to 'patchwork/templatetags')
-rw-r--r-- | patchwork/templatetags/patch.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/patchwork/templatetags/patch.py b/patchwork/templatetags/patch.py index 5d387a4..ea5a71d 100644 --- a/patchwork/templatetags/patch.py +++ b/patchwork/templatetags/patch.py @@ -36,9 +36,29 @@ def patch_checks(patch): titles = ['Success', 'Warning', 'Fail'] counts = patch.check_count + check_elements = [] + use_color = True + for state in required[::-1]: + if counts[state]: + if use_color: + use_color = False + color = dict(Check.STATE_CHOICES).get(state) + else: + color = '' + count = str(counts[state]) + else: + color = '' + count = '-' + + check_elements.append( + '<span class="patchlistchecks {}">{}</span>'.format( + color, count)) + + check_elements.reverse() + return mark_safe('<span title="%s">%s</span>' % ( ' / '.join(titles), - ' '.join([str(counts[state]) for state in required]))) + ''.join(check_elements))) @register.filter |