diff --git a/vrobbler/apps/charts/models.py b/vrobbler/apps/charts/models.py index acbdaaa..6f673af 100644 --- a/vrobbler/apps/charts/models.py +++ b/vrobbler/apps/charts/models.py @@ -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}") diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 545cd42..b26551a 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -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 diff --git a/vrobbler/templates/boardgames/boardgame_detail.html b/vrobbler/templates/boardgames/boardgame_detail.html index f7456a5..e86a89e 100644 --- a/vrobbler/templates/boardgames/boardgame_detail.html +++ b/vrobbler/templates/boardgames/boardgame_detail.html @@ -50,7 +50,7 @@ {% if charts %}
-

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %}
{% endif %} diff --git a/vrobbler/templates/books/book_detail.html b/vrobbler/templates/books/book_detail.html index f9c138d..8e7c3b1 100644 --- a/vrobbler/templates/books/book_detail.html +++ b/vrobbler/templates/books/book_detail.html @@ -44,7 +44,7 @@ {% if charts %}
-

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %}
{% endif %} diff --git a/vrobbler/templates/foods/food_detail.html b/vrobbler/templates/foods/food_detail.html index c292559..91c0684 100644 --- a/vrobbler/templates/foods/food_detail.html +++ b/vrobbler/templates/foods/food_detail.html @@ -4,16 +4,17 @@ {% block title %}{{object.title}}{% endblock %} {% block lists %} +{% if object.description %}

{{object.description}}

-{{charts}} +{% endif %} {% if charts %}
-

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %}
{% endif %} diff --git a/vrobbler/templates/music/album_detail.html b/vrobbler/templates/music/album_detail.html index 4cd1ec6..c7c2db7 100644 --- a/vrobbler/templates/music/album_detail.html +++ b/vrobbler/templates/music/album_detail.html @@ -33,7 +33,7 @@

{{object.scrobbles.count}} scrobbles

{% if charts %} -

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %} {% endif %}

Top tracks

diff --git a/vrobbler/templates/music/artist_detail.html b/vrobbler/templates/music/artist_detail.html index 89bcd85..487ee1c 100644 --- a/vrobbler/templates/music/artist_detail.html +++ b/vrobbler/templates/music/artist_detail.html @@ -34,7 +34,7 @@

{{artist.scrobbles.count}} scrobbles

{% if charts %} -

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %} {% endif %}

Top tracks

diff --git a/vrobbler/templates/music/track_detail.html b/vrobbler/templates/music/track_detail.html index 22edcbc..2c55bd4 100644 --- a/vrobbler/templates/music/track_detail.html +++ b/vrobbler/templates/music/track_detail.html @@ -11,7 +11,7 @@

{{scrobbles.count}} scrobbles

{% if charts %} -

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %} {% endif %}

Last scrobbles

diff --git a/vrobbler/templates/podcasts/podcast_detail.html b/vrobbler/templates/podcasts/podcast_detail.html index 8cb07d2..32d0d8f 100644 --- a/vrobbler/templates/podcasts/podcast_detail.html +++ b/vrobbler/templates/podcasts/podcast_detail.html @@ -34,7 +34,7 @@ {% if charts %}
-

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %}
{% endif %} diff --git a/vrobbler/templates/scrobbles/_chart_links.html b/vrobbler/templates/scrobbles/_chart_links.html new file mode 100644 index 0000000..fc9c934 --- /dev/null +++ b/vrobbler/templates/scrobbles/_chart_links.html @@ -0,0 +1,7 @@ +{% if charts %} +
+
+

{% for chart in charts %}{{chart.rank_emoji}} {{chart.period_str}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+
+
+{% endif %} diff --git a/vrobbler/templates/scrobbles/scrobble_detail.html b/vrobbler/templates/scrobbles/scrobble_detail.html index 57c2961..fa81091 100644 --- a/vrobbler/templates/scrobbles/scrobble_detail.html +++ b/vrobbler/templates/scrobbles/scrobble_detail.html @@ -11,8 +11,8 @@

-{% 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 }}

+{% 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 %}{% endif %}{{ object.media_obj }}{% if object.media_obj.get_absolute_url %}{% endif %} {% if object.media_type == "Task" and object.logdata.title %}

{{ object.logdata.title }}

{% endif %} diff --git a/vrobbler/templates/trails/trail_detail.html b/vrobbler/templates/trails/trail_detail.html index 150d881..cf50d2c 100644 --- a/vrobbler/templates/trails/trail_detail.html +++ b/vrobbler/templates/trails/trail_detail.html @@ -47,7 +47,7 @@ {% if charts %}
-

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %}
{% endif %} diff --git a/vrobbler/templates/videos/series_detail.html b/vrobbler/templates/videos/series_detail.html index dca82d7..910d560 100644 --- a/vrobbler/templates/videos/series_detail.html +++ b/vrobbler/templates/videos/series_detail.html @@ -47,7 +47,7 @@ {% if charts %}
-

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

+ {% include "scrobbles/_chart_links.html" %}
{% endif %} diff --git a/vrobbler/templates/videos/video_detail.html b/vrobbler/templates/videos/video_detail.html index 51e9791..f7769a2 100644 --- a/vrobbler/templates/videos/video_detail.html +++ b/vrobbler/templates/videos/video_detail.html @@ -83,9 +83,7 @@ dd {
- {% if charts %} -

{% for chart in charts %}{{chart}}{% if forloop.last %}{% else %} | {% endif %}{% endfor %}

- {% endif %} + {% include "scrobbles/_chart_links.html" %}

Last scrobbles