From: Ali Alnubani Date: Tue, 8 Jan 2019 12:38:47 +0000 (+0000) Subject: Beautify check counts in the patch list view X-Git-Tag: v2.2.0-rc1~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=974ff0c9959db22371907c22c0c0ff5bb079ebf2;p=thirdparty%2Fpatchwork.git 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 Signed-off-by: Ali Alnubani Signed-off-by: Stephen Finucane --- diff --git a/htdocs/css/style.css b/htdocs/css/style.css index af2f0732..c0f4561a 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -236,6 +236,26 @@ table.patchmeta tr th, table.patchmeta tr td { text-decoration: underline; } +.patchlistchecks { + display: inline-block; + border-radius: 7px; + min-width: 0.9em; + padding: 0 2px; + text-align: center; +} + +.patchlistchecks.success { + background-color: #82ca9d; +} + +.patchlistchecks.warning { + background-color: #ffc95e; +} + +.patchlistchecks.fail { + background-color: #ff5555; +} + .checks .state { font-weight: bold; color: #ddd; diff --git a/patchwork/templatetags/patch.py b/patchwork/templatetags/patch.py index 5d387a49..ea5a71de 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( + '{}'.format( + color, count)) + + check_elements.reverse() + return mark_safe('%s' % ( ' / '.join(titles), - ' '.join([str(counts[state]) for state in required]))) + ''.join(check_elements))) @register.filter