Commit bd7b5705 authored by Janelle Co's avatar Janelle Co

Populated some of the tables.

parent 27263ab3
# Generated by Django 3.2.12 on 2022-11-30 08:34
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('booking', '0002_rename_fname_crew_member_first_name_and_more'),
]
operations = [
migrations.RenameField(
model_name='booking',
old_name='P_ID',
new_name='Passenger',
),
migrations.AlterField(
model_name='flight',
name='Destination_Airport',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='destination', to='booking.city'),
),
migrations.AlterField(
model_name='flight',
name='Flight_Code',
field=models.CharField(max_length=6),
),
migrations.AlterField(
model_name='flight',
name='Origin_Airport',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='origin', to='booking.city'),
),
migrations.AlterField(
model_name='passenger',
name='Middle_Initial',
field=models.CharField(blank=True, max_length=50),
),
migrations.AlterField(
model_name='passenger',
name='Phone_num',
field=models.CharField(max_length=11, validators=[django.core.validators.RegexValidator('^[0-9]*$', message='Please input numbers only')]),
),
]
# Generated by Django 3.2.12 on 2022-11-30 08:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('booking', '0003_auto_20221130_0834'),
]
operations = [
migrations.AddField(
model_name='schedule',
name='Arrival_Time',
field=models.TimeField(default=0),
),
migrations.AddField(
model_name='schedule',
name='Departure_Time',
field=models.TimeField(default=0),
),
]
# Generated by Django 3.2.12 on 2022-11-30 08:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('booking', '0004_auto_20221130_0855'),
]
operations = [
migrations.AlterField(
model_name='schedule',
name='Arrival_Time',
field=models.CharField(max_length=5),
),
migrations.AlterField(
model_name='schedule',
name='Departure_Time',
field=models.CharField(max_length=5),
),
]
# Generated by Django 3.2.12 on 2022-11-30 09:02
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('booking', '0005_auto_20221130_0856'),
]
operations = [
migrations.RemoveField(
model_name='schedule',
name='Arrival_Time',
),
migrations.RemoveField(
model_name='schedule',
name='Departure_Time',
),
]
...@@ -6,7 +6,7 @@ from django.core.validators import RegexValidator,EmailValidator ...@@ -6,7 +6,7 @@ from django.core.validators import RegexValidator,EmailValidator
class Passenger(models.Model): class Passenger(models.Model):
P_ID = models.AutoField(primary_key=True, editable=False, unique=True) P_ID = models.AutoField(primary_key=True, editable=False, unique=True)
First_Name = models.CharField(max_length=50) First_Name = models.CharField(max_length=50)
Middle_Initial = models.CharField(max_length=50) Middle_Initial = models.CharField(max_length=50, blank=True)
Last_Name = models.CharField(max_length = 50) Last_Name = models.CharField(max_length = 50)
Birthdate = models.DateField Birthdate = models.DateField
Age = models.CharField(max_length=3) Age = models.CharField(max_length=3)
...@@ -24,41 +24,26 @@ class Passenger(models.Model): ...@@ -24,41 +24,26 @@ class Passenger(models.Model):
default=na, default=na,
) )
Phone_num = models.CharField(max_length = 7, validators=[RegexValidator(r'^\d{0,9}$',message = "Please input numbers only")]) Phone_num = models.CharField(max_length = 11, validators=[RegexValidator(r'^[0-9]*$',message = "Please input numbers only")])
Email_add = models.EmailField(max_length = 254, validators=[EmailValidator()]) Email_add = models.EmailField(max_length = 254, validators=[EmailValidator()])
def __str__(self):
return self.First_Name + ' ' + self.Last_Name
class Booking(models.Model): class Booking(models.Model):
Booking_ID = models.AutoField(primary_key=True, editable=False, unique=True) Booking_ID = models.AutoField(primary_key=True, editable=False, unique=True)
Booking_Date = models.DateField Booking_Date = models.DateField
Total_Cost = models.CharField(max_length=100) Total_Cost = models.CharField(max_length=100)
P_ID = models.ForeignKey(Passenger, on_delete=models.CASCADE) Passenger = models.ForeignKey(Passenger, on_delete=models.CASCADE)
class Flight(models.Model):
Flight_ID = models.AutoField(primary_key=True, editable=False, unique=True)
Flight_Code = models.CharField(max_length=5)
Origin_Airport = models.CharField(max_length=100)
Destination_Airport = models.CharField(max_length=100)
class Schedule(models.Model):
Sched_Code = models.AutoField(primary_key=True, editable=False, unique=True)
Flight_Date = models.DateField
Departure_Time = models.TimeField
Arrival_Time = models.TimeField
Duration = models.CharField(max_length=50)
Flight_Cost = models.CharField(max_length=50)
Flight_Code = models.ForeignKey(Flight, on_delete=models.CASCADE)
class Booking_Sched(models.Model):
class Meta:
unique_together = ('Booking_ID', 'Sched_Code')
Booking_ID = models.ForeignKey(Booking, on_delete=models.CASCADE)
Sched_Code = models.ForeignKey(Schedule, on_delete=models.CASCADE)
class Additional_Item(models.Model): class Additional_Item(models.Model):
Description = models.CharField(max_length=50, primary_key=True, editable=False, unique=True) Description = models.CharField(max_length=50, primary_key=True, editable=True, unique=True)
Item_Cost = models.IntegerField(default=0) Item_Cost = models.IntegerField(default=0)
def __str__(self):
return self.Description
class Booking_AddItem(models.Model): class Booking_AddItem(models.Model):
class Meta: class Meta:
unique_together = ('Booking_ID', 'AddItem_Desc') unique_together = ('Booking_ID', 'AddItem_Desc')
...@@ -73,6 +58,9 @@ class City(models.Model): ...@@ -73,6 +58,9 @@ class City(models.Model):
City_Name = models.CharField(max_length=50) City_Name = models.CharField(max_length=50)
Country = models.CharField(max_length=50) Country = models.CharField(max_length=50)
def __str__(self):
return self.Airport_name + ' (' + self.Country + ')'
class Crew_Member(models.Model): class Crew_Member(models.Model):
Employee_ID = models.AutoField(primary_key=True, editable=False, unique=True) Employee_ID = models.AutoField(primary_key=True, editable=False, unique=True)
First_Name = models.CharField(max_length=50) First_Name = models.CharField(max_length=50)
...@@ -87,12 +75,8 @@ class Crew_Member(models.Model): ...@@ -87,12 +75,8 @@ class Crew_Member(models.Model):
Role = models.CharField(max_length=50, choices=role_choices) Role = models.CharField(max_length=50, choices=role_choices)
class Sched_Crew(models.Model): def __str__(self):
class Meta: return self.First_Name + ' ' + self.Last_Name + ' (' + self.Role + ')'
unique_together = ('Sched_Code', 'Employee_ID')
Sched_Code = models.ForeignKey(Schedule, on_delete=models.CASCADE)
Employee_ID = models.ForeignKey(Crew_Member, on_delete=models.CASCADE)
class Pilot(models.Model): class Pilot(models.Model):
Employee_ID = models.OneToOneField(Crew_Member, on_delete=models.CASCADE, primary_key=True) Employee_ID = models.OneToOneField(Crew_Member, on_delete=models.CASCADE, primary_key=True)
...@@ -110,6 +94,9 @@ class Pilot(models.Model): ...@@ -110,6 +94,9 @@ class Pilot(models.Model):
] ]
Rank = models.CharField(max_length=50, choices=rank_choices) Rank = models.CharField(max_length=50, choices=rank_choices)
def __str__(self):
return self.Employee_ID.First_Name + ' ' + self.Employee_ID.Last_Name + ' (' + self.Rank + ')'
class Flight_Attendant(models.Model): class Flight_Attendant(models.Model):
Employee_ID = models.OneToOneField(Crew_Member, on_delete=models.CASCADE, primary_key=True) Employee_ID = models.OneToOneField(Crew_Member, on_delete=models.CASCADE, primary_key=True)
economy = 'Economy' economy = 'Economy'
...@@ -123,3 +110,38 @@ class Flight_Attendant(models.Model): ...@@ -123,3 +110,38 @@ class Flight_Attendant(models.Model):
(first_class, 'First Class') (first_class, 'First Class')
] ]
Assigned_Class = models.CharField(max_length=50, choices=class_choices) Assigned_Class = models.CharField(max_length=50, choices=class_choices)
def __str__(self):
return self.Employee_ID.First_Name + ' ' + self.Employee_ID.Last_Name + ' (' + self.Assigned_Class + ')'
class Flight(models.Model):
Flight_ID = models.AutoField(primary_key=True, editable=False, unique=True)
Flight_Code = models.CharField(max_length=6)
Origin_Airport = models.ForeignKey(City, on_delete=models.CASCADE, related_name='origin')
Destination_Airport = models.ForeignKey(City, on_delete=models.CASCADE, related_name='destination')
def __str__(self):
return ' (' + self.Flight_Code + ' ' + self.Origin_Airport.City_Name + ' to ' + self.Destination_Airport.City_Name
class Schedule(models.Model):
Sched_Code = models.AutoField(primary_key=True, editable=False, unique=True)
Flight_Date = models.DateField
Departure_Time = models.TimeField
Arrival_Time = models.TimeField
Duration = models.CharField(max_length=50)
Flight_Cost = models.CharField(max_length=50)
Flight_Code = models.ForeignKey(Flight, on_delete=models.CASCADE)
class Sched_Crew(models.Model):
class Meta:
unique_together = ('Sched_Code', 'Employee_ID')
Sched_Code = models.ForeignKey(Schedule, on_delete=models.CASCADE)
Employee_ID = models.ForeignKey(Crew_Member, on_delete=models.CASCADE)
class Booking_Sched(models.Model):
class Meta:
unique_together = ('Booking_ID', 'Sched_Code')
Booking_ID = models.ForeignKey(Booking, on_delete=models.CASCADE)
Sched_Code = models.ForeignKey(Schedule, on_delete=models.CASCADE)
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment