[templates] Clean up chart displays
This commit is contained in:
@ -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}")
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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 %}
|
||||
|
||||
@ -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 %}
|
||||
|
||||
@ -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 %}
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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 %}
|
||||
|
||||
7
vrobbler/templates/scrobbles/_chart_links.html
Normal file
7
vrobbler/templates/scrobbles/_chart_links.html
Normal 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 %}
|
||||
@ -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 %}
|
||||
|
||||
@ -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 %}
|
||||
|
||||
@ -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 %}
|
||||
|
||||
@ -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">
|
||||
|
||||
Reference in New Issue
Block a user