kumify/gpslog/models.py

36 lines
1.2 KiB
Python
Raw Normal View History

2022-09-09 16:59:13 +00:00
from django.contrib.gis.db import models
from django.contrib.auth import get_user_model
2022-09-07 16:15:22 +00:00
2022-09-09 16:59:13 +00:00
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)
2022-09-09 16:59:13 +00:00
satellites = models.IntegerField(null=True, blank=True)
user_agent = models.TextField(null=True, blank=True)