Allow pkg_details_link to honor package flag state

This allows the tag to be used in a few more places we weren't already
able to use it, and hopefully speeds up rendering a tad on the package
differences page.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2013-11-27 16:07:49 -05:00
parent e557545ca8
commit 58356ec5b3
2 changed files with 7 additions and 8 deletions

View File

@ -67,13 +67,16 @@ def do_buildsortqs(parser, token):
@register.simple_tag
def pkg_details_link(pkg, link_title=None):
def pkg_details_link(pkg, link_title=None, honor_flagged=False):
if not pkg:
return link_title or ''
if link_title is None:
link_title = pkg.pkgname
link_content = link_title
if honor_flagged and pkg.flag_date:
link_content = '<span class="flagged">%s</span>' % link_title
link = '<a href="%s" title="View package details for %s">%s</a>'
return link % (pkg.get_absolute_url(), pkg.pkgname, link_title)
return link % (pkg.get_absolute_url(), pkg.pkgname, link_content)
@register.simple_tag

View File

@ -46,14 +46,10 @@ <h3>Filter Differences View</h3>
<td>{{ diff.pkgname }}</td>
<td>{{ diff.repo.name }}</td>
{% if diff.pkg_a %}
<td><a href="{{ diff.pkg_a.get_absolute_url }}"
title="View package details for {{ diff.pkg_a.pkgname }}">
<span{% if diff.pkg_a.flag_date %} class="flagged"{% endif %}>{{ diff.pkg_a.full_version }}</span></a></td>
<td>{% pkg_details_link diff.pkg_a diff.pkg_a.full_version True %}</td>
{% else %}<td>-</td>{% endif %}
{% if diff.pkg_b %}
<td><a href="{{ diff.pkg_b.get_absolute_url }}"
title="View package details for {{ diff.pkg_b.pkgname }}">
<span{% if diff.pkg_b.flag_date %} class="flagged"{% endif %}>{{ diff.pkg_b.full_version }}</span></a></td>
<td>{% pkg_details_link diff.pkg_b diff.pkg_b.full_version True %}</td>
{% else %}<td>-</td>{% endif %}
</tr>
{% endfor %}