Browse Source

Try and fix things

Colin Powell 1 year ago
parent
commit
da944f9ef1

+ 6 - 0
vrobbler/apps/locations/apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class LocationConfig(AppConfig):
+    name = "locations"
+

+ 1 - 0
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}

+ 5 - 0
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:

+ 1 - 1
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()

+ 1 - 1
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__)