Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Fetch HLTB main/extra/completionist hours when a game item is saved - Re-fetch only when name or category changes on edit - Steam imports also fetch HLTB for each selected game - Cards show compact HLTB row: "HLTB: 40h · +extra 60h · 100% 100h" - Edit form shows HLTB breakdown as a hint next to Total hours field Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
from django.contrib.auth.models import User
|
|
from django.db import models
|
|
|
|
|
|
class Item(models.Model):
|
|
GAMES = 'games'
|
|
BOOKS = 'books'
|
|
FILMS = 'films'
|
|
OTHER = 'other'
|
|
CATEGORY_CHOICES = [
|
|
(GAMES, 'Games'),
|
|
(BOOKS, 'Books'),
|
|
(FILMS, 'Films'),
|
|
(OTHER, 'Other'),
|
|
]
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='items', null=True)
|
|
|
|
category = models.CharField(max_length=10, choices=CATEGORY_CHOICES)
|
|
name = models.CharField(max_length=200)
|
|
progress_percent = models.FloatField(default=0.0)
|
|
favorite = models.BooleanField(default=False)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
# Games
|
|
hours_played = models.FloatField(null=True, blank=True)
|
|
total_hours = models.FloatField(null=True, blank=True)
|
|
|
|
# Books
|
|
pages_read = models.IntegerField(null=True, blank=True)
|
|
total_pages = models.IntegerField(null=True, blank=True)
|
|
|
|
# Films
|
|
watched = models.BooleanField(null=True, blank=True)
|
|
duration_minutes = models.IntegerField(null=True, blank=True)
|
|
|
|
# HowLongToBeat estimates (games only)
|
|
hltb_main = models.FloatField(null=True, blank=True)
|
|
hltb_extra = models.FloatField(null=True, blank=True)
|
|
hltb_complete = models.FloatField(null=True, blank=True)
|
|
|
|
class Meta:
|
|
ordering = ['-favorite', 'name']
|
|
|
|
def __str__(self):
|
|
return f"{self.get_category_display()}: {self.name}"
|