Add ability to manage long plays

This commit is contained in:
2023-03-11 14:11:31 -05:00
parent 6e03cf5075
commit bb2a80e2aa
9 changed files with 179 additions and 38 deletions

View File

@ -1,5 +1,4 @@
import logging
from typing import Optional
from uuid import uuid4
from django.conf import settings
@ -7,7 +6,7 @@ from django.contrib.auth import get_user_model
from django.db import models
from django.urls import reverse
from django_extensions.db.models import TimeStampedModel
from scrobbles.mixins import ScrobblableMixin
from scrobbles.mixins import LongPlayScrobblableMixin
from scrobbles.utils import get_scrobbles_for_media
from videogames.igdb import lookup_game_id_from_gdb
@ -46,7 +45,7 @@ class VideoGameCollection(TimeStampedModel):
)
class VideoGame(ScrobblableMixin):
class VideoGame(LongPlayScrobblableMixin):
COMPLETION_PERCENT = getattr(settings, "GAME_COMPLETION_PERCENT", 100)
FIELDS_FROM_IGDB = [
@ -89,6 +88,10 @@ class VideoGame(ScrobblableMixin):
def __str__(self):
return self.title
@property
def subtitle(self):
return f" On {self.platforms.first()}"
def get_absolute_url(self):
return reverse(
"videogames:videogame_detail", kwargs={"slug": self.uuid}
@ -101,6 +104,9 @@ class VideoGame(ScrobblableMixin):
slug = self.title.lower().replace(" ", "-")
return f"https://igdb.com/games/{slug}"
def get_start_url(self):
return reverse("scrobbles:start", kwargs={"uuid": self.uuid})
def save(self, **kwargs):
super().save(**kwargs)
self.fix_metadata()