Commit 44b78f78 authored by Janelle Co's avatar Janelle Co

Made the tables but still not completely finished yet.

parent 2b8f9815
File added
"""
ASGI config for MagisAir project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MagisAir.settings')
application = get_asgi_application()
"""
Django settings for MagisAir project.
Generated by 'django-admin startproject' using Django 3.2.12.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-o9+x6b*o&r$#j#a_qe8d(n%xunjeyvt)dsnnt&mqtk^)dvzhbk'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'booking.apps.BookingConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'MagisAir.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'MagisAir.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
"""MagisAir URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('booking/', include("booking.urls")),
path('admin/', admin.site.urls),
]
"""
WSGI config for MagisAir project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MagisAir.settings')
application = get_wsgi_application()
from django.contrib import admin
from .models import Passenger, Booking, Schedule, Sched_Crew, City, Crew_Member, Additional_Item, Flight
# Register your models here.
admin.site.register(Passenger)
admin.site.register(Booking)
admin.site.register(Sched_Crew)
admin.site.register(Schedule)
admin.site.register(City)
admin.site.register(Crew_Member)
admin.site.register(Additional_Item)
admin.site.register(Flight)
from django.apps import AppConfig
class BookingConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'booking'
# Generated by Django 3.2.12 on 2022-11-24 06:22
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Additional_Item',
fields=[
('Description', models.CharField(editable=False, max_length=50, primary_key=True, serialize=False, unique=True)),
('Item_Cost', models.CharField(max_length=20)),
],
),
migrations.CreateModel(
name='City',
fields=[
('Airport_Code', models.AutoField(editable=False, primary_key=True, serialize=False, unique=True)),
('Airport_name', models.CharField(max_length=50)),
('City_Name', models.CharField(max_length=50)),
('Country', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='Crew_Member',
fields=[
('Employee_ID', models.AutoField(editable=False, primary_key=True, serialize=False, unique=True)),
('Fname', models.CharField(max_length=50)),
('Lname', models.CharField(max_length=50)),
('Role', models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name='Flight',
fields=[
('Flight_ID', models.AutoField(editable=False, primary_key=True, serialize=False, unique=True)),
('Flight_Code', models.CharField(max_length=5)),
('Origin_Airport', models.CharField(max_length=100)),
('Destination_Airport', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='Passenger',
fields=[
('P_ID', models.AutoField(editable=False, primary_key=True, serialize=False, unique=True)),
('Fname', models.CharField(max_length=50)),
('MI', models.CharField(max_length=50)),
('Lname', models.CharField(max_length=50)),
('Age', models.CharField(max_length=3)),
('Gender', models.CharField(choices=[('Male', 'Male'), ('Female', 'Female'), ('Prefer not to say', 'Prefer not to say')], default='Prefer not to say', max_length=20)),
('Phone_num', models.CharField(max_length=7, validators=[django.core.validators.RegexValidator('^\\d{0,9}$', message='Please input numbers only')])),
('Email_add', models.EmailField(max_length=254, validators=[django.core.validators.EmailValidator()])),
],
),
migrations.CreateModel(
name='Schedule',
fields=[
('Sched_Code', models.AutoField(editable=False, primary_key=True, serialize=False, unique=True)),
('Duration', models.CharField(max_length=50)),
('Flight_Cost', models.CharField(max_length=50)),
('Flight_Code', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='booking.flight')),
],
),
migrations.CreateModel(
name='Booking',
fields=[
('Booking_ID', models.AutoField(editable=False, primary_key=True, serialize=False, unique=True)),
('Total_Cost', models.CharField(max_length=100)),
('P_ID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='booking.passenger')),
],
),
migrations.CreateModel(
name='Sched_Crew',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('Employee_ID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='booking.crew_member')),
('Sched_Code', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='booking.schedule')),
],
options={
'unique_together': {('Sched_Code', 'Employee_ID')},
},
),
]
from django.db import models
from django.core.validators import RegexValidator,EmailValidator
# Create your models here.
class Passenger(models.Model):
P_ID = models.AutoField(primary_key=True, editable=False, unique=True)
Fname = models.CharField(max_length=50)
MI = models.CharField(max_length=50)
Lname = models.CharField(max_length = 50)
Birthdate = models.DateField
Age = models.CharField(max_length=3)
male = 'Male'
female = 'Female'
na = 'Prefer not to say'
gender_choices = [
(male, 'Male'),
(female, 'Female'),
(na, 'Prefer not to say'),
]
Gender = models.CharField(
max_length=20,
choices=gender_choices,
default=na,
)
Phone_num = models.CharField(max_length = 7, validators=[RegexValidator(r'^\d{0,9}$',message = "Please input numbers only")])
Email_add = models.EmailField(max_length = 254, validators=[EmailValidator()])
class Booking(models.Model):
Booking_ID = models.AutoField(primary_key=True, editable=False, unique=True)
Booking_Date = models.DateField
Total_Cost = models.CharField(max_length=100)
P_ID = models.ForeignKey(Passenger, on_delete=models.CASCADE)
class Crew_Member(models.Model):
Employee_ID = models.AutoField(primary_key=True, editable=False, unique=True)
Fname = models.CharField(max_length=50)
Lname = models.CharField(max_length = 50)
Role = models.CharField(max_length=50)
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 Additional_Item(models.Model):
Description = models.CharField(max_length=50, primary_key=True, editable=False, unique=True)
Item_Cost = models.CharField(max_length=20)
class Schedule(models.Model):
Sched_Code = models.AutoField(primary_key=True, editable=False, unique=True)
Flight_Date = models.DateField
Departure_Time = models.TimeField
Arrical_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 City(models.Model):
Airport_Code = models.AutoField(primary_key=True, editable=False, unique=True)
Airport_name = models.CharField(max_length=50)
City_Name = models.CharField(max_length=50)
Country = models.CharField(max_length=50)
from django.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index")
]
\ No newline at end of file
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("booking index")
\ No newline at end of file
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MagisAir.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
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