-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
330d2b0
commit feb1b68
Showing
3 changed files
with
88 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Patchwork - automated patch tracking system | ||
# Copyright (C) 2008 Jeremy Kerr <[email protected]> | ||
# Copyright (C) 2015 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
from django import template | ||
from django.utils.safestring import mark_safe | ||
|
||
from patchwork.models import Check | ||
|
||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter(name='series_tags') | ||
def series_tags(series): | ||
counts = [] | ||
titles = [] | ||
|
||
for tag in [t for t in series.project.tags if t.show_column]: | ||
count = 0 | ||
for patch in series.patches.with_tag_counts(series.project).all(): | ||
count += getattr(patch, tag.attr_name) | ||
|
||
titles.append('%d %s' % (count, tag.name)) | ||
if count == 0: | ||
counts.append('-') | ||
else: | ||
counts.append(str(count)) | ||
|
||
return mark_safe( | ||
'<span title="%s">%s</span>' % (' / '.join(titles), ' '.join(counts)) | ||
) | ||
|
||
|
||
@register.filter(name='series_checks') | ||
def series_checks(series): | ||
required = [Check.STATE_SUCCESS, Check.STATE_WARNING, Check.STATE_FAIL] | ||
titles = ['Success', 'Warning', 'Fail'] | ||
counts = series.check_count | ||
|
||
check_elements = [] | ||
for state in required[::-1]: | ||
if counts[state]: | ||
color = dict(Check.STATE_CHOICES).get(state) | ||
count = str(counts[state]) | ||
else: | ||
color = '' | ||
count = '-' | ||
|
||
check_elements.append( | ||
f'<span class="patchlistchecks {color}">{count}</span>' | ||
) | ||
|
||
check_elements.reverse() | ||
|
||
return mark_safe( | ||
'<span title="%s">%s</span>' | ||
% (' / '.join(titles), ''.join(check_elements)) | ||
) |