initial commit
This commit is contained in:
commit
c6961c03c3
33 changed files with 1782 additions and 0 deletions
106
stratoflights_api/models.py
Normal file
106
stratoflights_api/models.py
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import uuid
|
||||
from django.db import models
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import AbstractUser, AnonymousUser
|
||||
|
||||
|
||||
class User(AbstractUser):
|
||||
satellites = models.ManyToManyField("Satellite", related_name="users")
|
||||
|
||||
|
||||
class Prediction(models.Model):
|
||||
user = models.ForeignKey(get_user_model(
|
||||
), on_delete=models.CASCADE, default=0, related_name='predictions')
|
||||
satellite = models.ForeignKey(
|
||||
'Satellite', on_delete=models.CASCADE, related_name='predictions', null=True)
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
request = models.JSONField(default=dict)
|
||||
result = models.JSONField(default=dict)
|
||||
start_point = models.ForeignKey(
|
||||
'SavedPoint', on_delete=models.SET_NULL, related_name='predictions', null=True)
|
||||
template = models.ForeignKey(
|
||||
'PreditctionTemplate', on_delete=models.SET_NULL, related_name='predictions', null=True)
|
||||
rate_profile = models.ForeignKey(
|
||||
'SavedRateProfile', on_delete=models.SET_NULL, related_name='predictions', null=True)
|
||||
|
||||
|
||||
class Satellite(models.Model):
|
||||
user = models.ForeignKey(
|
||||
get_user_model(), on_delete=models.CASCADE, default=0)
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
name = models.CharField(max_length=100)
|
||||
metadata = models.JSONField(blank=True, default=dict)
|
||||
image = models.ImageField(
|
||||
upload_to='satellite_images/', blank=True, null=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
|
||||
class TelemetryPacket(models.Model):
|
||||
user = models.ForeignKey(
|
||||
get_user_model(), on_delete=models.CASCADE, default=0)
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
satellite = models.ForeignKey(
|
||||
Satellite, on_delete=models.CASCADE, related_name="telemetry")
|
||||
timestamp = models.BigIntegerField() # unix time
|
||||
lat = models.FloatField(default=0.0)
|
||||
lon = models.FloatField(default=0.0)
|
||||
alt = models.FloatField(default=0.0)
|
||||
payload = models.JSONField(blank=True, default=dict)
|
||||
raw_data = models.JSONField(blank=True, default=dict)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
|
||||
class PreditctionTemplate(models.Model):
|
||||
user = models.ForeignKey(
|
||||
get_user_model(), on_delete=models.CASCADE, default=0)
|
||||
name = models.CharField(max_length=100)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
is_default = models.BooleanField(default=False)
|
||||
|
||||
description = models.TextField(blank=True, null=True)
|
||||
prediction_mode = models.CharField(
|
||||
max_length=50,
|
||||
default="") # TODO: add choices for prediction modes
|
||||
model = models.CharField(
|
||||
max_length=50,
|
||||
default="") # TODO: add choices for models
|
||||
dataset = models.CharField(
|
||||
max_length=50,
|
||||
default="")
|
||||
flight_parameters = models.JSONField(blank=True, default=dict)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('user', 'name')
|
||||
|
||||
|
||||
class SavedPoint(models.Model):
|
||||
user = models.ForeignKey(
|
||||
get_user_model(), on_delete=models.CASCADE, default=0)
|
||||
name = models.CharField(max_length=100)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
lat = models.FloatField(default=0.0)
|
||||
lon = models.FloatField(default=0.0)
|
||||
alt = models.FloatField(default=0.0)
|
||||
is_default = models.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('user', 'name')
|
||||
|
||||
|
||||
class SavedRateProfile(models.Model):
|
||||
user = models.ForeignKey(
|
||||
get_user_model(), on_delete=models.CASCADE, default=0)
|
||||
name = models.CharField(max_length=100)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
type = models.CharField(
|
||||
max_length=50, default="ascent") # TODO: add choices for rate profile types
|
||||
rate_profile_data = models.JSONField(blank=True, default=dict)
|
||||
is_default = models.BooleanField(default=False)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('user', 'name')
|
||||
Loading…
Add table
Add a link
Reference in a new issue