From da944f9ef19bd5ee8f1ec345d9183fc6ab345865 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 24 Nov 2023 14:33:09 +0100 Subject: [PATCH] Try and fix things --- vrobbler/apps/locations/apps.py | 6 ++++++ vrobbler/apps/locations/models.py | 1 + vrobbler/apps/scrobbles/mixins.py | 5 +++++ vrobbler/apps/scrobbles/models.py | 2 +- vrobbler/apps/scrobbles/scrobblers.py | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 vrobbler/apps/locations/apps.py diff --git a/vrobbler/apps/locations/apps.py b/vrobbler/apps/locations/apps.py new file mode 100644 index 0000000..41f8e63 --- /dev/null +++ b/vrobbler/apps/locations/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class LocationConfig(AppConfig): + name = "locations" + diff --git a/vrobbler/apps/locations/models.py b/vrobbler/apps/locations/models.py index 6b49a7e..5472a6e 100644 --- a/vrobbler/apps/locations/models.py +++ b/vrobbler/apps/locations/models.py @@ -28,6 +28,7 @@ class GeoLocation(ScrobblableMixin): def __str__(self): return f"{self.lat} x {self.lon}" + def get_absolute_url(self): return reverse( "locations:geo_location_detail", kwargs={"slug": self.uuid} diff --git a/vrobbler/apps/scrobbles/mixins.py b/vrobbler/apps/scrobbles/mixins.py index 342c8e9..4a65ddf 100644 --- a/vrobbler/apps/scrobbles/mixins.py +++ b/vrobbler/apps/scrobbles/mixins.py @@ -56,6 +56,11 @@ class ScrobblableMixin(TimeStampedModel): def find_or_create(cls): logger.warn("find_or_create() not implemented yet") + def scrobble(self, user_id, **kwargs): + """Given a user ID and a dictionary of data, attempts to scrobble it""" + from scrobbles.models import Scrobble + Scrobble.create_or_update(self, user_id, **kwargs) + class LongPlayScrobblableMixin(ScrobblableMixin): class Meta: diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 7cfd748..b50b80f 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -13,6 +13,7 @@ from django.urls import reverse from django.utils import timezone from django.utils.functional import cached_property from django_extensions.db.models import TimeStampedModel +from locations.models import GeoLocation from music.lastfm import LastFM from music.models import Artist, Track from podcasts.models import Episode @@ -34,7 +35,6 @@ from sports.models import SportEvent from videogames import retroarch from videogames.models import VideoGame from videos.models import Series, Video -from locations.models import GeoLocation logger = logging.getLogger(__name__) User = get_user_model() diff --git a/vrobbler/apps/scrobbles/scrobblers.py b/vrobbler/apps/scrobbles/scrobblers.py index 0a358a0..9f9760d 100644 --- a/vrobbler/apps/scrobbles/scrobblers.py +++ b/vrobbler/apps/scrobbles/scrobblers.py @@ -24,7 +24,7 @@ from videogames.howlongtobeat import lookup_game_from_hltb from videogames.models import VideoGame from videos.models import Video from locations.models import GeoLocation, RawGeoLocation -from vrobbler.apps.locations.constants import LOCATION_PROVIDERS +from locations.constants import LOCATION_PROVIDERS logger = logging.getLogger(__name__)