From ba0be65ed036b49d22bad637a93c0f6aa9d3c0f8 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Tue, 20 Aug 2024 10:21:56 -0400 Subject: [PATCH] [scrobbles] Allow boardgame screenshots and clean up koreader fields --- vrobbler/apps/scrobbles/admin.py | 2 +- ...ve_scrobble_book_koreader_hash_and_more.py | 47 +++++++++++++++++++ vrobbler/apps/scrobbles/models.py | 15 ++---- .../boardgames/boardgame_detail.html | 3 ++ .../templates/scrobbles/_last_scrobbles.html | 4 +- .../videogames/videogame_detail.html | 2 +- 6 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 vrobbler/apps/scrobbles/migrations/0059_remove_scrobble_book_koreader_hash_and_more.py diff --git a/vrobbler/apps/scrobbles/admin.py b/vrobbler/apps/scrobbles/admin.py index 1b9c5a1..f5af618 100644 --- a/vrobbler/apps/scrobbles/admin.py +++ b/vrobbler/apps/scrobbles/admin.py @@ -31,7 +31,7 @@ class ScrobbleInline(admin.TabularInline): "scrobble_log", "timezone", "videogame_save_data", - "videogame_screenshot", + "screenshot", ) diff --git a/vrobbler/apps/scrobbles/migrations/0059_remove_scrobble_book_koreader_hash_and_more.py b/vrobbler/apps/scrobbles/migrations/0059_remove_scrobble_book_koreader_hash_and_more.py new file mode 100644 index 0000000..71c2542 --- /dev/null +++ b/vrobbler/apps/scrobbles/migrations/0059_remove_scrobble_book_koreader_hash_and_more.py @@ -0,0 +1,47 @@ +# Generated by Django 4.2.15 on 2024-08-20 14:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("scrobbles", "0058_merge_20240810_2234"), + ] + + operations = [ + migrations.RemoveField( + model_name="scrobble", + name="book_koreader_hash", + ), + migrations.RemoveField( + model_name="scrobble", + name="book_page_data", + ), + migrations.RemoveField( + model_name="scrobble", + name="book_pages_read", + ), + migrations.RemoveField( + model_name="scrobble", + name="videogame_screenshot", + ), + migrations.AddField( + model_name="scrobble", + name="screenshot", + field=models.ImageField( + blank=True, + null=True, + upload_to="scrobbles/videogame_screenshot/", + ), + ), + migrations.AlterField( + model_name="scrobble", + name="videogame_save_data", + field=models.FileField( + blank=True, + null=True, + upload_to="scrobbles/videogame_save_data/", + ), + ), + ] diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 927a73c..41780b5 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -536,26 +536,21 @@ class Scrobble(TimeStampedModel): ) timezone = models.CharField(max_length=50, **BNULL) - # Fields for keeping track of book data DEPRECATED, remove after migration - book_koreader_hash = models.CharField(max_length=50, **BNULL) - book_pages_read = models.IntegerField(**BNULL) - book_page_data = models.JSONField(**BNULL) - # Fields for keeping track of video game data videogame_save_data = models.FileField( upload_to="scrobbles/videogame_save_data/", **BNULL ) - videogame_screenshot = models.ImageField( + screenshot = models.ImageField( upload_to="scrobbles/videogame_screenshot/", **BNULL ) - videogame_screenshot_small = ImageSpecField( - source="videogame_screenshot", + screenshot_small = ImageSpecField( + source="screenshot", processors=[ResizeToFit(100, 100)], format="JPEG", options={"quality": 60}, ) - videogame_screenshot_medium = ImageSpecField( - source="videogame_screenshot", + screenshot_medium = ImageSpecField( + source="screenshot", processors=[ResizeToFit(300, 300)], format="JPEG", options={"quality": 75}, diff --git a/vrobbler/templates/boardgames/boardgame_detail.html b/vrobbler/templates/boardgames/boardgame_detail.html index 4e2c8e8..cc15593 100644 --- a/vrobbler/templates/boardgames/boardgame_detail.html +++ b/vrobbler/templates/boardgames/boardgame_detail.html @@ -56,13 +56,16 @@ Date Publisher + Screenshot {% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %} {{scrobble.timestamp}} + {{scrobble.logdata}} {{scrobble.media_obj.publisher}} + {% if scrobble.screenshot%}{% endif %} {% endfor %} diff --git a/vrobbler/templates/scrobbles/_last_scrobbles.html b/vrobbler/templates/scrobbles/_last_scrobbles.html index e917340..4ea2041 100644 --- a/vrobbler/templates/scrobbles/_last_scrobbles.html +++ b/vrobbler/templates/scrobbles/_last_scrobbles.html @@ -164,8 +164,8 @@ {% for scrobble in videogame_scrobble_list %} {{scrobble.timestamp|naturaltime}} - {% if scrobble.videogame_screenshot %} - + {% if scrobble.screenshot %} + {% else %} {% if scrobble.media_obj.hltb_cover %} diff --git a/vrobbler/templates/videogames/videogame_detail.html b/vrobbler/templates/videogames/videogame_detail.html index 1b27e66..55d1cd4 100644 --- a/vrobbler/templates/videogames/videogame_detail.html +++ b/vrobbler/templates/videogames/videogame_detail.html @@ -93,7 +93,7 @@ {% if scrobble.in_progress %}Now playing{% else %}{{scrobble.playback_position_seconds|natural_duration}}{% endif %} {% for platform in scrobble.video_game.platforms.all %}{{platform}}{% if not forloop.last %}, {% endif %}{% endfor %} {% if scrobble.videogame_save_data %}Save data{% else %}Not yet{% endif %} - {% if scrobble.videogame_screenshot%}{% endif %} + {% if scrobble.screenshot%}{% endif %} {% endfor %}