Files
k-boris-website/backlogger/models.py
Boris c84600ae3e
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
fix hltb worker
2026-04-02 21:23:00 +03:00

77 lines
2.4 KiB
Python

from django.contrib.auth.models import User
from django.db import models
class UserProfile(models.Model):
DARK = 'dark'
LIGHT = 'light'
THEME_CHOICES = [(DARK, 'Dark'), (LIGHT, 'Light')]
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
display_name = models.CharField(max_length=100, blank=True)
theme = models.CharField(max_length=10, choices=THEME_CHOICES, default=DARK)
def __str__(self):
return f"Profile({self.user.username})"
class Item(models.Model):
GAMES = 'games'
BOOKS = 'books'
FILMS = 'films'
OTHER = 'other'
CATEGORY_CHOICES = [
(GAMES, 'Games'),
(BOOKS, 'Books'),
(FILMS, 'Films'),
(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)
category = models.CharField(max_length=10, choices=CATEGORY_CHOICES)
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default=ACTIVE)
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)
# Steam
steam_appid = 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)
hltb_fetched = models.BooleanField(default=False)
class Meta:
ordering = ['-favorite', 'name']
def __str__(self):
return f"{self.get_category_display()}: {self.name}"