From b765067c5b48795baeb03b6ee4659ae5e37352d6 Mon Sep 17 00:00:00 2001 From: Boris Date: Wed, 1 Apr 2026 23:25:41 +0300 Subject: [PATCH] Add unending category for session-based games MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For games like Dota 2 that have no completion state — shows hours played on the card, reuses the games fields in the form (hours played / total hours), and gets its own cyan badge. No DB column change, only choices metadata update. Co-Authored-By: Claude Sonnet 4.6 --- .../migrations/0006_item_category_unending.py | 25 +++++++++++++++++++ backlogger/models.py | 2 ++ .../templates/backlogger/item_form.html | 4 ++- backlogger/templates/backlogger/list.html | 5 ++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 backlogger/migrations/0006_item_category_unending.py diff --git a/backlogger/migrations/0006_item_category_unending.py b/backlogger/migrations/0006_item_category_unending.py new file mode 100644 index 0000000..1849bad --- /dev/null +++ b/backlogger/migrations/0006_item_category_unending.py @@ -0,0 +1,25 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('backlogger', '0005_item_status'), + ] + + operations = [ + migrations.AlterField( + model_name='item', + name='category', + field=models.CharField( + choices=[ + ('games', 'Games'), + ('books', 'Books'), + ('films', 'Films'), + ('unending', 'Unending'), + ('other', 'Other'), + ], + max_length=10, + ), + ), + ] diff --git a/backlogger/models.py b/backlogger/models.py index 962cd47..fd0b374 100644 --- a/backlogger/models.py +++ b/backlogger/models.py @@ -6,11 +6,13 @@ class Item(models.Model): GAMES = 'games' BOOKS = 'books' FILMS = 'films' + UNENDING = 'unending' OTHER = 'other' CATEGORY_CHOICES = [ (GAMES, 'Games'), (BOOKS, 'Books'), (FILMS, 'Films'), + (UNENDING, 'Unending'), (OTHER, 'Other'), ] diff --git a/backlogger/templates/backlogger/item_form.html b/backlogger/templates/backlogger/item_form.html index ea5e449..dbd6d6a 100644 --- a/backlogger/templates/backlogger/item_form.html +++ b/backlogger/templates/backlogger/item_form.html @@ -252,7 +252,9 @@ function updateSections() { document.querySelectorAll('.cat-section').forEach(el => el.style.display = 'none'); - const sec = document.getElementById('section-' + catSelect.value); + const cat = catSelect.value; + const secId = cat === 'unending' ? 'section-games' : 'section-' + cat; + const sec = document.getElementById(secId); if (sec) sec.style.display = 'block'; } diff --git a/backlogger/templates/backlogger/list.html b/backlogger/templates/backlogger/list.html index a87801e..9c93fe4 100644 --- a/backlogger/templates/backlogger/list.html +++ b/backlogger/templates/backlogger/list.html @@ -120,6 +120,7 @@ .badge-games { background: #3b2f6a; color: #a78bfa; } .badge-books { background: #064e3b; color: #34d399; } .badge-films { background: #431407; color: #fb923c; } + .badge-unending { background: #0c3a52; color: #38bdf8; } .badge-other { background: #1e293b; color: #94a3b8; } .star { color: #fbbf24; font-size: 0.9rem; margin-left: auto; } @@ -233,6 +234,10 @@ {% if item.pages_read is not None %} {{ item.pages_read }} pages{% if item.total_pages %} / {{ item.total_pages }} total{% endif %} {% endif %} + {% elif item.category == 'unending' %} + {% if item.hours_played is not None %} + {{ item.hours_played|floatformat:1 }}h played + {% endif %} {% elif item.category == 'films' %} {% if item.watched %}✓ Watched{% else %}○ Not watched{% endif %}{% if item.duration_minutes %} · {{ item.duration_minutes }} min{% endif %} {% endif %}