diff --git a/backlogger/migrations/0006_item_category_unending.py b/backlogger/migrations/0006_item_status_unending.py similarity index 68% rename from backlogger/migrations/0006_item_category_unending.py rename to backlogger/migrations/0006_item_status_unending.py index 1849bad..85485ba 100644 --- a/backlogger/migrations/0006_item_category_unending.py +++ b/backlogger/migrations/0006_item_status_unending.py @@ -10,15 +10,15 @@ class Migration(migrations.Migration): operations = [ migrations.AlterField( model_name='item', - name='category', + name='status', field=models.CharField( choices=[ - ('games', 'Games'), - ('books', 'Books'), - ('films', 'Films'), + ('active', 'Active'), + ('completed', 'Completed'), + ('abandoned', 'Abandoned'), ('unending', 'Unending'), - ('other', 'Other'), ], + default='active', max_length=10, ), ), diff --git a/backlogger/models.py b/backlogger/models.py index fd0b374..fa8394b 100644 --- a/backlogger/models.py +++ b/backlogger/models.py @@ -6,23 +6,23 @@ 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'), ] ACTIVE = 'active' COMPLETED = 'completed' ABANDONED = 'abandoned' + UNENDING = 'unending' STATUS_CHOICES = [ (ACTIVE, 'Active'), (COMPLETED, 'Completed'), (ABANDONED, 'Abandoned'), + (UNENDING, 'Unending'), ] user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='items', null=True) diff --git a/backlogger/templates/backlogger/item_form.html b/backlogger/templates/backlogger/item_form.html index dbd6d6a..ea5e449 100644 --- a/backlogger/templates/backlogger/item_form.html +++ b/backlogger/templates/backlogger/item_form.html @@ -252,9 +252,7 @@ function updateSections() { document.querySelectorAll('.cat-section').forEach(el => el.style.display = 'none'); - const cat = catSelect.value; - const secId = cat === 'unending' ? 'section-games' : 'section-' + cat; - const sec = document.getElementById(secId); + const sec = document.getElementById('section-' + catSelect.value); if (sec) sec.style.display = 'block'; } diff --git a/backlogger/templates/backlogger/list.html b/backlogger/templates/backlogger/list.html index 9c93fe4..ee7a285 100644 --- a/backlogger/templates/backlogger/list.html +++ b/backlogger/templates/backlogger/list.html @@ -120,7 +120,6 @@ .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; } @@ -184,6 +183,7 @@ Active Completed Abandoned + Unending {% if shelf == 'active' %} All @@ -234,10 +234,6 @@ {% 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 %} @@ -252,6 +248,14 @@ + {% if item.category == 'games' %} +
+ {% csrf_token %} + + + +
+ {% endif %}
{% csrf_token %} diff --git a/backlogger/views.py b/backlogger/views.py index 0d18254..11040ab 100644 --- a/backlogger/views.py +++ b/backlogger/views.py @@ -36,7 +36,7 @@ def item_list(request): category = request.GET.get('category', '') sort = request.GET.get('sort', 'fav') shelf = request.GET.get('shelf', Item.ACTIVE) - if shelf not in (Item.ACTIVE, Item.COMPLETED, Item.ABANDONED): + if shelf not in (Item.ACTIVE, Item.COMPLETED, Item.ABANDONED, Item.UNENDING): shelf = Item.ACTIVE items = Item.objects.filter(user=request.user, status=shelf) @@ -88,7 +88,7 @@ def item_set_status(request, pk): if request.method == 'POST': item = get_object_or_404(Item, pk=pk, user=request.user) new_status = request.POST.get('status') - if new_status in (Item.ACTIVE, Item.COMPLETED, Item.ABANDONED): + if new_status in (Item.ACTIVE, Item.COMPLETED, Item.ABANDONED, Item.UNENDING): item.status = new_status item.save(update_fields=['status', 'updated_at']) next_url = request.POST.get('next') or reverse('backlogger:list')