kumify/gpslog/models.py
Kumi a6025dee31
fix: Switches DecimalFields to FloatFields in GPSPoint
Converts battery, accuracy, speed, and bearing fields from
DecimalField to FloatField in GPSPoint model for improved
performance and simplified operations. Updates migration to
reflect these changes, ensuring consistency across the database.
2024-11-18 06:42:36 +01:00

35 lines
1.2 KiB
Python

from django.contrib.gis.db import models
from django.contrib.auth import get_user_model
from uuid import uuid4
class GPSTrack(models.Model):
id = models.UUIDField(default=uuid4, primary_key=True)
user = models.ForeignKey(get_user_model(), models.CASCADE)
class GPSToken(models.Model):
name = models.CharField(max_length=128, null=True, blank=True)
track = models.ForeignKey(GPSTrack, models.CASCADE)
token = models.UUIDField(default=uuid4)
# Permissions
read = models.BooleanField(default=False)
write = models.BooleanField(default=False)
history = models.BooleanField(default=False)
class GPSPoint(models.Model):
track = models.ForeignKey(GPSTrack, models.CASCADE)
point = models.PointField()
timestamp = models.DateTimeField()
token = models.ForeignKey(GPSToken, models.SET_NULL, null=True)
# Optional additional information
battery = models.FloatField(null=True, blank=True)
accuracy = models.FloatField(null=True, blank=True)
speed = models.FloatField(null=True, blank=True)
bearing = models.FloatField(null=True, blank=True)
satellites = models.IntegerField(null=True, blank=True)
user_agent = models.TextField(null=True, blank=True)