prediction templates
This commit is contained in:
parent
9bf24b072b
commit
576db57d99
4 changed files with 65 additions and 5 deletions
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Generated by Django 4.2.23 on 2025-07-08 10:17
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('api', '0003_prediction_rate_profile_prediction_start_point_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='preditctiontemplate',
|
||||||
|
name='template_data',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='preditctiontemplate',
|
||||||
|
name='dataset',
|
||||||
|
field=models.CharField(default='', max_length=50),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='preditctiontemplate',
|
||||||
|
name='description',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='preditctiontemplate',
|
||||||
|
name='flight_parameters',
|
||||||
|
field=models.JSONField(blank=True, default=dict),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='preditctiontemplate',
|
||||||
|
name='model',
|
||||||
|
field=models.CharField(default='', max_length=50),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='preditctiontemplate',
|
||||||
|
name='prediction_mode',
|
||||||
|
field=models.CharField(default='', max_length=50),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='savedrateprofile',
|
||||||
|
name='type',
|
||||||
|
field=models.CharField(default='ascent', max_length=50),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -58,9 +58,20 @@ class PreditctionTemplate(models.Model):
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
template_data = models.JSONField(blank=True, default=dict)
|
|
||||||
is_default = models.BooleanField(default=False)
|
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:
|
class Meta:
|
||||||
unique_together = ('user', 'name')
|
unique_together = ('user', 'name')
|
||||||
|
|
||||||
|
|
@ -86,6 +97,8 @@ class SavedRateProfile(models.Model):
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(auto_now=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)
|
rate_profile_data = models.JSONField(blank=True, default=dict)
|
||||||
is_default = models.BooleanField(default=False)
|
is_default = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,14 +147,14 @@ class SavedPointSerializer(serializers.ModelSerializer):
|
||||||
class SavedRateProfileSerializer(serializers.ModelSerializer):
|
class SavedRateProfileSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SavedRateProfile
|
model = SavedRateProfile
|
||||||
fields = ['id', 'name', 'rate_profile_data']
|
fields = ['id', 'name', 'type', 'rate_profile_data']
|
||||||
read_only_fields = ['id']
|
read_only_fields = ['id']
|
||||||
|
|
||||||
|
|
||||||
class PreditctionTemplateSerializer(serializers.ModelSerializer):
|
class PreditctionTemplateSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PreditctionTemplate
|
model = PreditctionTemplate
|
||||||
fields = ['id', 'name', 'template_data', 'is_default']
|
fields = ['id', 'name', 'is_default', 'description', 'prediction_mode', 'model', 'dataset', 'flight_parameters']
|
||||||
read_only_fields = ['id']
|
read_only_fields = ['id']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
||||||
|
|
||||||
# Environment flag
|
# Environment flag
|
||||||
PRODUCTION = os.getenv('DJANGO_ENV') == 'production'
|
PRODUCTION = os.getenv('DJANGO_ENV', "") == 'production'
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = os.getenv(
|
SECRET_KEY = os.getenv(
|
||||||
|
|
@ -104,7 +104,7 @@ ASGI_APPLICATION = 'testapi.asgi.application'
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||||
|
|
||||||
if PRODUCTION:
|
if not PRODUCTION:
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue