|
@@ -1,11 +1,13 @@
|
|
|
-from decimal import Decimal, getcontext
|
|
|
import logging
|
|
|
+from dataclasses import dataclass
|
|
|
+from decimal import Decimal
|
|
|
from typing import Dict
|
|
|
|
|
|
-from django.contrib.auth import get_user_model
|
|
|
from django.conf import settings
|
|
|
+from django.contrib.auth import get_user_model
|
|
|
from django.db import models
|
|
|
from django.urls import reverse
|
|
|
+from scrobbles.dataclasses import BaseLogData, WithPeopleLogData
|
|
|
from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
@@ -15,6 +17,9 @@ User = get_user_model()
|
|
|
GEOLOC_ACCURACY = int(getattr(settings, "GEOLOC_ACCURACY", 4))
|
|
|
GEOLOC_PROXIMITY = Decimal(getattr(settings, "GEOLOC_PROXIMITY", "0.0001"))
|
|
|
|
|
|
+@dataclass
|
|
|
+class GeoLocationLogData(BaseLogData, WithPeopleLogData):
|
|
|
+ pass
|
|
|
|
|
|
class GeoLocation(ScrobblableMixin):
|
|
|
COMPLETION_PERCENT = getattr(settings, "LOCATION_COMPLETION_PERCENT", 100)
|
|
@@ -39,6 +44,10 @@ class GeoLocation(ScrobblableMixin):
|
|
|
"locations:geolocation_detail", kwargs={"slug": self.uuid}
|
|
|
)
|
|
|
|
|
|
+ @property
|
|
|
+ def logdata_cls(self):
|
|
|
+ return GeoLocationLogData
|
|
|
+
|
|
|
@classmethod
|
|
|
def find_or_create(cls, data_dict: Dict) -> "GeoLocation":
|
|
|
"""Given a data dict from GPSLogger, does the heavy lifting of looking up
|