2019-09-15 05:38:18 +00:00
|
|
|
from django.db import models
|
2019-09-16 00:32:42 +00:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
2019-09-15 05:38:18 +00:00
|
|
|
from decimal import Decimal
|
2019-09-16 00:32:42 +00:00
|
|
|
|
2019-09-15 05:38:18 +00:00
|
|
|
# Create your models here.
|
|
|
|
|
2019-09-16 00:32:42 +00:00
|
|
|
|
2019-09-15 05:38:18 +00:00
|
|
|
class Plane(models.Model):
|
|
|
|
tail_number = models.CharField(max_length=64, primary_key=True) # "N43337"
|
2019-09-16 00:32:42 +00:00
|
|
|
name = models.CharField(max_length=64) # "Warrior II"
|
|
|
|
manufacturer = models.CharField(max_length=64) # Piper
|
|
|
|
model = models.CharField(max_length=64) # PA28-151
|
|
|
|
engine_count = models.IntegerField(default=1)
|
2019-09-15 05:38:18 +00:00
|
|
|
|
2019-09-16 00:32:42 +00:00
|
|
|
def __str__(self):
|
2019-09-15 05:38:18 +00:00
|
|
|
return self.tail_number
|
|
|
|
|
2019-09-16 00:32:42 +00:00
|
|
|
|
2019-09-15 05:38:18 +00:00
|
|
|
class Airport(models.Model):
|
|
|
|
icao = models.CharField(max_length=4, primary_key=True)
|
2019-09-16 00:32:42 +00:00
|
|
|
link = models.CharField(max_length=256, blank=True)
|
2019-09-15 05:38:18 +00:00
|
|
|
|
2019-09-16 00:32:42 +00:00
|
|
|
def __str__(self):
|
2019-09-15 05:38:18 +00:00
|
|
|
return self.icao
|
|
|
|
|
2019-09-16 00:32:42 +00:00
|
|
|
|
2019-09-15 05:38:18 +00:00
|
|
|
class Flight(models.Model):
|
2019-09-16 00:32:42 +00:00
|
|
|
flight_date = models.DateField() # "flight_date": "2019-08-31",
|
|
|
|
|
2019-09-15 05:38:18 +00:00
|
|
|
plane = models.ForeignKey(Plane, on_delete=models.PROTECT)
|
2019-09-16 00:32:42 +00:00
|
|
|
airport_depart = models.ForeignKey(
|
|
|
|
Airport, on_delete=models.PROTECT, related_name="%(class)s_from"
|
|
|
|
) # "from": "KEEN",
|
|
|
|
airport_arrive = models.ForeignKey(
|
|
|
|
Airport, on_delete=models.PROTECT, related_name="%(class)s_to"
|
|
|
|
) # "to": "KEEN",
|
2019-09-15 05:38:18 +00:00
|
|
|
|
2019-09-16 00:32:42 +00:00
|
|
|
user = models.ForeignKey(User, on_delete=models.PROTECT)
|
|
|
|
|
|
|
|
instructor = models.CharField(
|
|
|
|
max_length=64, blank=True
|
|
|
|
) # "instructor": "Gene Moody",
|
|
|
|
remarks = models.TextField(
|
|
|
|
blank=True
|
|
|
|
) # "remarks": "normal to/l, shortfield to/l, std turns, constant speed, constant descents",
|
2019-09-15 05:38:18 +00:00
|
|
|
|
|
|
|
landings = models.IntegerField()
|
|
|
|
|
2019-09-16 00:32:42 +00:00
|
|
|
airplane_sel_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
|
|
|
airplane_mel_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
|
|
|
cross_country_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
2019-09-15 05:38:18 +00:00
|
|
|
day_time = models.DecimalField(max_digits=2, decimal_places=1, default=Decimal(0.0))
|
2019-09-16 00:32:42 +00:00
|
|
|
night_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
|
|
|
actual_instrument_time = models.DecimalField(
|
|
|
|
decimal_places=1, max_digits=2, default=Decimal(0.0)
|
|
|
|
)
|
|
|
|
simulated_instrument_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
|
|
|
ground_trainer_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
|
|
|
dual_received_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
|
|
|
pilot_in_command_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
|
|
|
total_time = models.DecimalField(
|
|
|
|
max_digits=2, decimal_places=1, default=Decimal(0.0)
|
|
|
|
)
|
2019-09-15 05:38:18 +00:00
|
|
|
|
|
|
|
link = models.CharField(max_length=200, blank=True)
|
|
|
|
|
2019-09-16 00:32:42 +00:00
|
|
|
leg = models.IntegerField(default=0)
|
|
|
|
|
2019-09-15 05:38:18 +00:00
|
|
|
def __str__(self):
|
2019-09-16 00:32:42 +00:00
|
|
|
return f"{self.flight_date}: {self.plane} {self.total_time}h - {self.airport_depart} -> {self.airport_arrive}"
|