models and stuff
This commit is contained in:
parent
73c090f413
commit
1074d17fb0
195
.gitignore
vendored
Normal file
195
.gitignore
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/python,django
|
||||
# Edit at https://www.gitignore.io/?templates=python,django
|
||||
|
||||
### Django ###
|
||||
*.log
|
||||
*.pot
|
||||
*.pyc
|
||||
__pycache__/
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
media
|
||||
|
||||
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
|
||||
# in your Git repository. Update and uncomment the following line accordingly.
|
||||
# <django-project-name>/staticfiles/
|
||||
|
||||
### Django.Python Stack ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Django stuff:
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
|
||||
# C extensions
|
||||
|
||||
# Distribution / packaging
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
|
||||
# Installer logs
|
||||
|
||||
# Unit test / coverage reports
|
||||
|
||||
# Translations
|
||||
|
||||
# Django stuff:
|
||||
|
||||
# Flask stuff:
|
||||
|
||||
# Scrapy stuff:
|
||||
|
||||
# Sphinx documentation
|
||||
|
||||
# PyBuilder
|
||||
|
||||
# Jupyter Notebook
|
||||
|
||||
# IPython
|
||||
|
||||
# pyenv
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
|
||||
# celery beat schedule file
|
||||
|
||||
# SageMath parsed files
|
||||
|
||||
# Environments
|
||||
|
||||
# Spyder project settings
|
||||
|
||||
# Rope project settings
|
||||
|
||||
# mkdocs documentation
|
||||
|
||||
# mypy
|
||||
|
||||
# Pyre type checker
|
||||
|
||||
# End of https://www.gitignore.io/api/python,django
|
||||
|
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
||||
https://www.pydanny.com/drf-jwt-axios-vue.html
|
||||
https://medium.com/@williamgnlee/simple-integrated-django-vue-js-web-application-configured-for-heroku-deployment-c4bd2b37aa70
|
0
logbook/flight/__init__.py
Normal file
0
logbook/flight/__init__.py
Normal file
17
logbook/flight/admin.py
Normal file
17
logbook/flight/admin.py
Normal file
@ -0,0 +1,17 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from flight.models import Flight, Plane, Airport
|
||||
# Register your models here.
|
||||
|
||||
|
||||
class FlightAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
admin.site.register(Flight, FlightAdmin)
|
||||
|
||||
class PlaneAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
admin.site.register(Plane, PlaneAdmin)
|
||||
|
||||
class AirportAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
admin.site.register(Airport, AirportAdmin)
|
5
logbook/flight/apps.py
Normal file
5
logbook/flight/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class FlightConfig(AppConfig):
|
||||
name = 'flight'
|
56
logbook/flight/migrations/0001_initial.py
Normal file
56
logbook/flight/migrations/0001_initial.py
Normal file
@ -0,0 +1,56 @@
|
||||
# Generated by Django 2.2.5 on 2019-09-15 05:25
|
||||
|
||||
from decimal import Decimal
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Airport',
|
||||
fields=[
|
||||
('icao', models.CharField(max_length=4, primary_key=True, serialize=False)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Plane',
|
||||
fields=[
|
||||
('tail_number', models.CharField(max_length=64, primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=64)),
|
||||
('manufacturer', models.CharField(max_length=64)),
|
||||
('model', models.CharField(max_length=64)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Flight',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('flight_date', models.DateField()),
|
||||
('instructor', models.CharField(blank=True, max_length=64)),
|
||||
('remarks', models.TextField(blank=True)),
|
||||
('landings', models.IntegerField()),
|
||||
('airplane_sel_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('airplane_mel_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('cross_country_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('day_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('night_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('actual_instrument_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('simulated_instrument_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('ground_trainer_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('dual_received_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('pilot_in_command_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('total_time', models.DecimalField(decimal_places=1, default=Decimal('0'), max_digits=2)),
|
||||
('link', models.CharField(blank=True, max_length=200)),
|
||||
('airport_arrive', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='flight_to', to='flight.Airport')),
|
||||
('airport_depart', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='flight_from', to='flight.Airport')),
|
||||
('plane', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='flight.Plane')),
|
||||
],
|
||||
),
|
||||
]
|
0
logbook/flight/migrations/__init__.py
Normal file
0
logbook/flight/migrations/__init__.py
Normal file
46
logbook/flight/models.py
Normal file
46
logbook/flight/models.py
Normal file
@ -0,0 +1,46 @@
|
||||
from django.db import models
|
||||
from decimal import Decimal
|
||||
# Create your models here.
|
||||
|
||||
class Plane(models.Model):
|
||||
tail_number = models.CharField(max_length=64, primary_key=True) # "N43337"
|
||||
name = models.CharField(max_length=64) # "Warrior II"
|
||||
manufacturer = models.CharField(max_length=64) # Piper
|
||||
model = models.CharField(max_length=64) # PA28-151
|
||||
|
||||
def __str__ (self):
|
||||
return self.tail_number
|
||||
|
||||
class Airport(models.Model):
|
||||
icao = models.CharField(max_length=4, primary_key=True)
|
||||
|
||||
def __str__ (self):
|
||||
return self.icao
|
||||
|
||||
class Flight(models.Model):
|
||||
flight_date = models.DateField() # "flight_date": "2019-08-31",
|
||||
plane = models.ForeignKey(Plane, 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",
|
||||
|
||||
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",
|
||||
|
||||
landings = models.IntegerField()
|
||||
|
||||
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))
|
||||
day_time = models.DecimalField(max_digits=2, decimal_places=1, default=Decimal(0.0))
|
||||
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))
|
||||
|
||||
link = models.CharField(max_length=200, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.plane} {self.total_time}h - {self.airport_depart} -> {self.airport_arrive}"
|
3
logbook/flight/tests.py
Normal file
3
logbook/flight/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
logbook/flight/views.py
Normal file
3
logbook/flight/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
@ -29,7 +29,8 @@ INSTALLED_APPS = [
|
||||
|
||||
'rest_framework',
|
||||
'rest_framework.authtoken',
|
||||
'corsheaders'
|
||||
'corsheaders',
|
||||
'flight',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@ -68,8 +69,12 @@ WSGI_APPLICATION = 'logbook.wsgi.application'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'logbook',
|
||||
'USER': os.environ.get('DJANGO_DB_NAME', ''),
|
||||
'PASSWORD': os.environ.get('DJANGO_DB_PASS', ''),
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT': '5433',
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,4 @@ from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
url(r'^api/v1/auth/obtain_token/', obtain_jwt_token),
|
||||
url(r'^api/v1/auth/refresh_token/', refresh_jwt_token),
|
||||
# The rest of the endpoints
|
||||
url(r'^api/v1/', include('project.api', namespace='apiv1')),
|
||||
]
|
||||
|
@ -1,5 +1,8 @@
|
||||
Django
|
||||
djangorestframework
|
||||
django-cors-headers
|
||||
djangorestframework-jwt
|
||||
|
||||
Django==2.2.5
|
||||
django-cors-headers==3.1.0
|
||||
djangorestframework==3.10.3
|
||||
djangorestframework-jwt==1.11.0
|
||||
psycopg2==2.8.3
|
||||
PyJWT==1.7.1
|
||||
pytz==2019.2
|
||||
sqlparse==0.3.0
|
||||
|
Loading…
Reference in New Issue
Block a user