42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
from django.core.validators import MaxValueValidator, MinValueValidator
|
|
from django.db import models
|
|
from django.utils import timezone
|
|
|
|
|
|
class Game(models.Model):
|
|
class Status(models.TextChoices):
|
|
BACKLOG = 'BL', 'Backlog'
|
|
WISHLIST = 'WL', 'Wishlist'
|
|
PLAYING = 'PL', 'Playing'
|
|
COMPLETED = 'CP', 'Completed'
|
|
RETIRED = 'RT', 'Retired'
|
|
|
|
title = models.CharField(max_length=200)
|
|
added = models.DateTimeField(default=timezone.now)
|
|
|
|
# IGDB Data
|
|
igdb_id = models.IntegerField(null=True, blank=True)
|
|
release_date = models.DateField(null=True, blank=True)
|
|
platforms = models.CharField(max_length=500, blank=True)
|
|
poster_url = models.URLField(max_length=500, blank=True)
|
|
game_modes = models.CharField(max_length=500, blank=True)
|
|
|
|
# Time to beat (in hours)
|
|
normally = models.FloatField(null=True, blank=True)
|
|
hastily = models.FloatField(null=True, blank=True)
|
|
completely = models.FloatField(null=True, blank=True)
|
|
|
|
# Playthrough details
|
|
status = models.CharField(max_length=2, choices=Status.choices, default=Status.BACKLOG)
|
|
owned_platforms = models.CharField(max_length=500, blank=True)
|
|
progress = models.IntegerField(
|
|
null=True, blank=True, validators=[MinValueValidator(0), MaxValueValidator(100)]
|
|
)
|
|
rating = models.IntegerField(
|
|
null=True, blank=True, validators=[MinValueValidator(0), MaxValueValidator(10)]
|
|
)
|
|
notes = models.TextField(blank=True)
|
|
last_played = models.DateTimeField(null=True, blank=True)
|
|
|
|
def __str__(self) -> str:
|
|
return str(self.title)
|