[templates] Clean up chart displays
Some checks failed
build & deploy / test (push) Successful in 1m49s
build & deploy / deploy (push) Failing after 2m4s

This commit is contained in:
2026-04-02 10:54:16 -04:00
parent ce7128c7ac
commit 1bf558938d
14 changed files with 27 additions and 16 deletions

View File

@ -146,3 +146,8 @@ class ChartRecord(TimeStampedModel):
elif self.month:
date_str = f"{self.year}-{self.month:02d}"
return f"{url}?date={date_str}"
@property
def rank_emoji(self) -> str:
emojis = {1: "🥇", 2: "🥈", 3: "🥉"}
return emojis.get(self.rank, f"#{self.rank}")

View File

@ -153,7 +153,7 @@ class ChartContextMixin:
if media_type:
context["charts"] = ChartRecord.objects.filter(
**{media_type: obj}, rank__in=[1, 2, 3]
)
).exclude(day__isnull=False)
return context

View File

@ -50,7 +50,7 @@
{% if charts %}
<div class="row">
<div class="col-md">
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
</div>
</div>
{% endif %}

View File

@ -44,7 +44,7 @@
{% if charts %}
<div class="row">
<div class="col-md">
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
</div>
</div>
{% endif %}

View File

@ -4,16 +4,17 @@
{% block title %}{{object.title}}{% endblock %}
{% block lists %}
{% if object.description %}
<div class="row webpage">
<div class="webpage-metadata">
<p>{{object.description}}</p>
</div>
</div>
{{charts}}
{% endif %}
{% if charts %}
<div class="row">
<div class="col-md">
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
</div>
</div>
{% endif %}

View File

@ -33,7 +33,7 @@
<div class="row">
<p>{{object.scrobbles.count}} scrobbles</p>
{% if charts %}
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
{% endif %}
<div class="col-md">
<h3>Top tracks</h3>

View File

@ -34,7 +34,7 @@
<div class="row">
<p>{{artist.scrobbles.count}} scrobbles</p>
{% if charts %}
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
{% endif %}
<div class="col-md">
<h3>Top tracks</h3>

View File

@ -11,7 +11,7 @@
<div class="row">
<p>{{scrobbles.count}} scrobbles</p>
{% if charts %}
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
{% endif %}
<div class="col-md">
<h3>Last scrobbles</h3>

View File

@ -34,7 +34,7 @@
{% if charts %}
<div class="row">
<div class="col-md">
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
</div>
</div>
{% endif %}

View File

@ -0,0 +1,7 @@
{% if charts %}
<div class="row">
<div class="col-md">
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart.rank_emoji}} {{chart.period_str}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
</div>
</div>
{% endif %}

View File

@ -11,8 +11,8 @@
<div class="row">
<h1>
{% if object.media_type == "Video" %}🎬{% elif object.media_type == "Track" %}🎵{% elif object.media_type == "PodcastEpisode" %}🎙️{% elif object.media_type == "SportEvent" %}⚽{% elif object.media_type == "Book" %}📚{% elif object.media_type == "Paper" %}📄{% elif object.media_type == "VideoGame" %}🎮{% elif object.media_type == "BoardGame" %}🎲{% elif object.media_type == "GeoLocation" %}📍{% elif object.media_type == "Trail" %}🥾{% elif object.media_type == "Beer" %}🍺{% elif object.media_type == "Puzzle" %}🧩{% elif object.media_type == "Food" %}🍔{% elif object.media_type == "Task" %}✅{% elif object.media_type == "WebPage" %}🌐{% elif object.media_type == "LifeEvent" %}🎉{% elif object.media_type == "Mood" %}😊{% elif object.media_type == "BrickSet" %}🧱{% endif %}
{{ object.media_obj }}</h1>
{% if object.media_type == "Video" %}🎬{% elif object.media_type == "Track" %}🎵{% elif object.media_type == "PodcastEpisode" %}🎙️{% elif object.media_type == "SportEvent" %}⚽{% elif object.media_type == "Book" %}📚{% elif object.media_type == "Paper" %}📄{% elif object.media_type == "VideoGame" %}🎮{% elif object.media_type == "BoardGame" %}🎲{% elif object.media_type == "GeoLocation" %}📍{% elif object.media_type == "Trail" %}🥾{% elif object.media_type == "Beer" %}🍺{% elif object.media_type == "Puzzle" %}🧩{% elif object.media_type == "Food" %}🍔{% elif object.media_type == "Task" %}✅{% elif object.media_type == "WebPage" %}🌐{% elif object.media_type == "LifeEvent" %}🎉{% elif object.media_type == "Mood" %}😊{% elif object.media_type == "BrickSet" %}🧱{% elif object.media_type == "Channel" %}📺{% endif %}
{% if object.media_obj.get_absolute_url %}<a href="{{ object.media_obj.get_absolute_url }}">{% endif %}{{ object.media_obj }}{% if object.media_obj.get_absolute_url %}</a>{% endif %}</h1>
{% if object.media_type == "Task" and object.logdata.title %}
<h2>{{ object.logdata.title }}</h2>
{% endif %}

View File

@ -47,7 +47,7 @@
{% if charts %}
<div class="row">
<div class="col-md">
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
</div>
</div>
{% endif %}

View File

@ -47,7 +47,7 @@
{% if charts %}
<div class="row">
<div class="col-md">
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% include "scrobbles/_chart_links.html" %}
</div>
</div>
{% endif %}

View File

@ -83,9 +83,7 @@ dd {
</div>
<div class="row">
<div class="col-md">
{% if charts %}
<p>{% for chart in charts %}<em><a href="{{chart.chart_url}}">{{chart}}</a></em>{% if forloop.last %}{% else %} | {% endif %}{% endfor %}</p>
{% endif %}
{% include "scrobbles/_chart_links.html" %}
<h3>Last scrobbles</h3>
<div class="table-responsive">
<table class="table table-striped table-sm">