maloja/maloja/web/jinja/partials/top_albums.jinja

31 lines
975 B
Django/Jinja

{% import 'snippets/links.jinja' as links %}
{% import 'snippets/entityrow.jinja' as entityrow %}
{% set ranges = dbc.get_top_albums(filterkeys,limitkeys,delimitkeys) %}
{% set maxbar = ranges|map(attribute="scrobbles")|max|default(1) %}
{% if maxbar < 1 %}{% set maxbar = 1 %}{% endif %}
<table class="list">
{% for e in ranges %}
{% set thisrange = e.range %}
{% set album = e.album %}
<tr>
<td><a href="{{ mlj_uri.create_uri("/charts_albums",{'timerange':thisrange}) }}">{{ thisrange.desc() }}</a></td>
{% if album is none %}
<td><div></div></td>
<td class='stats'>n/a</td>
<td class='amount'>0</td>
<td class='bar'></td>
{% else %}
{{ entityrow.row(album) }}
<td class='amount'>{{ links.link_scrobbles([{'album':album,'timerange':thisrange}],amount=e.scrobbles) }}</td>
<td class='bar'> {{ links.link_scrobbles([{'album':album,'timerange':thisrange}],percent=e.scrobbles*100/maxbar) }}</td>
{% endif %}
</tr>
{% endfor %}
</table>