From 8312e3b36a3bf2276e98b883bc1dbeb235ca9ffe Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Wed, 28 Jun 2017 12:37:02 -0400 Subject: Initial Setup --- app/.gitignore | 1 + app/app/__init__.py | 0 app/app/settings.py | 121 +++++++++++++++++++++ app/app/urls.py | 22 ++++ app/app/wsgi.py | 16 +++ app/dispatch/__init__.py | 0 app/dispatch/admin.py | 8 ++ app/dispatch/apps.py | 5 + app/dispatch/migrations/0001_initial.py | 30 +++++ app/dispatch/migrations/0002_auto_20170628_1516.py | 22 ++++ app/dispatch/migrations/0003_auto_20170628_1610.py | 47 ++++++++ app/dispatch/migrations/0004_auto_20170628_1611.py | 20 ++++ app/dispatch/migrations/0005_auto_20170628_1614.py | 21 ++++ app/dispatch/migrations/__init__.py | 0 app/dispatch/models.py | 46 ++++++++ app/dispatch/tests.py | 3 + app/dispatch/urls.py | 8 ++ app/dispatch/views.py | 8 ++ app/manage.py | 22 ++++ 19 files changed, 400 insertions(+) create mode 100644 app/.gitignore create mode 100644 app/app/__init__.py create mode 100644 app/app/settings.py create mode 100644 app/app/urls.py create mode 100644 app/app/wsgi.py create mode 100644 app/dispatch/__init__.py create mode 100644 app/dispatch/admin.py create mode 100644 app/dispatch/apps.py create mode 100644 app/dispatch/migrations/0001_initial.py create mode 100644 app/dispatch/migrations/0002_auto_20170628_1516.py create mode 100644 app/dispatch/migrations/0003_auto_20170628_1610.py create mode 100644 app/dispatch/migrations/0004_auto_20170628_1611.py create mode 100644 app/dispatch/migrations/0005_auto_20170628_1614.py create mode 100644 app/dispatch/migrations/__init__.py create mode 100644 app/dispatch/models.py create mode 100644 app/dispatch/tests.py create mode 100644 app/dispatch/urls.py create mode 100644 app/dispatch/views.py create mode 100755 app/manage.py (limited to 'app') diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..49ef255 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +db.sqlite3 diff --git a/app/app/__init__.py b/app/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/app/settings.py b/app/app/settings.py new file mode 100644 index 0000000..60e03fd --- /dev/null +++ b/app/app/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for app project. + +Generated by 'django-admin startproject' using Django 1.11.1. + +For more information on this file, see +https://docs.djangoproject.com/en/1.11/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.11/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'h$r_bwlp@#h#y#%&qhw-n=gb2%wva1d_h65+o94u&!a#%iv&lo' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'dispatch.apps.DispatchConfig', +] + +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 = 'app.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 = 'app.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.11/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/1.11/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/1.11/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/app/app/urls.py b/app/app/urls.py new file mode 100644 index 0000000..89d5431 --- /dev/null +++ b/app/app/urls.py @@ -0,0 +1,22 @@ +"""app URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.11/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import include, url +from django.contrib import admin + +urlpatterns = [ + url(r'^dispatch/', include('dispatch.urls')), + url(r'^admin/', admin.site.urls), +] diff --git a/app/app/wsgi.py b/app/app/wsgi.py new file mode 100644 index 0000000..cefd1ed --- /dev/null +++ b/app/app/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for app 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/1.11/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") + +application = get_wsgi_application() diff --git a/app/dispatch/__init__.py b/app/dispatch/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/dispatch/admin.py b/app/dispatch/admin.py new file mode 100644 index 0000000..e6617f2 --- /dev/null +++ b/app/dispatch/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin + +# Register your models here. +from .models import Load, Contact, Company + +admin.site.register(Load) +admin.site.register(Contact) +admin.site.register(Company) diff --git a/app/dispatch/apps.py b/app/dispatch/apps.py new file mode 100644 index 0000000..86aba5c --- /dev/null +++ b/app/dispatch/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class DispatchConfig(AppConfig): + name = 'dispatch' diff --git a/app/dispatch/migrations/0001_initial.py b/app/dispatch/migrations/0001_initial.py new file mode 100644 index 0000000..f3b4c88 --- /dev/null +++ b/app/dispatch/migrations/0001_initial.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.1 on 2017-06-28 15:15 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Load', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateField()), + ('company', models.CharField(max_length=256)), + ('description', models.CharField(max_length=256)), + ('amount', models.DecimalField(decimal_places=2, max_digits=10)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, unique=True)), + ], + ), + ] diff --git a/app/dispatch/migrations/0002_auto_20170628_1516.py b/app/dispatch/migrations/0002_auto_20170628_1516.py new file mode 100644 index 0000000..fb0b039 --- /dev/null +++ b/app/dispatch/migrations/0002_auto_20170628_1516.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.1 on 2017-06-28 15:16 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('dispatch', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='load', + name='user', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/app/dispatch/migrations/0003_auto_20170628_1610.py b/app/dispatch/migrations/0003_auto_20170628_1610.py new file mode 100644 index 0000000..839555a --- /dev/null +++ b/app/dispatch/migrations/0003_auto_20170628_1610.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.1 on 2017-06-28 16:10 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('dispatch', '0002_auto_20170628_1516'), + ] + + operations = [ + migrations.CreateModel( + name='Company', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=256)), + ('address', models.CharField(max_length=256)), + ('phone_number', models.DecimalField(decimal_places=0, max_digits=16)), + ('email_address', models.CharField(max_length=256)), + ], + ), + migrations.CreateModel( + name='Contact', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=64)), + ('last_name', models.CharField(max_length=64)), + ('phone_number', models.DecimalField(decimal_places=0, max_digits=16)), + ('email_address', models.CharField(max_length=256)), + ('the_company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dispatch.Company')), + ], + ), + migrations.AlterField( + model_name='load', + name='company', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='dispatch.Company'), + ), + migrations.AddField( + model_name='company', + name='primary_contact', + field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='dispatch.Contact'), + ), + ] diff --git a/app/dispatch/migrations/0004_auto_20170628_1611.py b/app/dispatch/migrations/0004_auto_20170628_1611.py new file mode 100644 index 0000000..ca6de59 --- /dev/null +++ b/app/dispatch/migrations/0004_auto_20170628_1611.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.1 on 2017-06-28 16:11 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('dispatch', '0003_auto_20170628_1610'), + ] + + operations = [ + migrations.RenameField( + model_name='contact', + old_name='the_company', + new_name='works_for', + ), + ] diff --git a/app/dispatch/migrations/0005_auto_20170628_1614.py b/app/dispatch/migrations/0005_auto_20170628_1614.py new file mode 100644 index 0000000..291b972 --- /dev/null +++ b/app/dispatch/migrations/0005_auto_20170628_1614.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.1 on 2017-06-28 16:14 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('dispatch', '0004_auto_20170628_1611'), + ] + + operations = [ + migrations.AlterField( + model_name='company', + name='primary_contact', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='dispatch.Contact'), + ), + ] diff --git a/app/dispatch/migrations/__init__.py b/app/dispatch/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/dispatch/models.py b/app/dispatch/models.py new file mode 100644 index 0000000..16703fd --- /dev/null +++ b/app/dispatch/models.py @@ -0,0 +1,46 @@ +from django.db import models +from django.conf import settings + +# Create your models here. + +class Company(models.Model): + name = models.CharField(max_length=256) + address = models.CharField(max_length=256) + phone_number = models.DecimalField(max_digits=16,decimal_places=0) + email_address = models.CharField(max_length=256) + primary_contact = models.ForeignKey('Contact', blank=True, null=True) + + def __str__(self): + return self.name + +class Contact(models.Model): + first_name = models.CharField(max_length=64) + last_name = models.CharField(max_length=64) + phone_number = models.DecimalField(max_digits=16,decimal_places=0) + email_address = models.CharField(max_length=256) + works_for = models.ForeignKey(Company) + + def __str__(self): + return "{f} {l} ( {c} )".format(c=self.works_for, f=self.first_name, l=self.last_name) + +class Load(models.Model): + date = models.DateField() + user = models.OneToOneField(settings.AUTH_USER_MODEL) + company = models.OneToOneField(Company) + description = models.CharField(max_length=256) + amount = models.DecimalField(max_digits=10,decimal_places=2) + + def __str__(self): + return "{c}, {d} ( {a} )".format(c=self.company, d=self.description, a=self.amount) + +# class Paperwork(models.Model): +# company = models.OneToOneField(Company) +# description = models.CharField(max_length=256) +# amount = models.DecimalField(max_digits=10,decimal_places=2) +# +# def __str__(self): +# return "{c}, {d} ( {a} )".format(c=self.company, d=self.description, a=self.amount) + + + + diff --git a/app/dispatch/tests.py b/app/dispatch/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/dispatch/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/dispatch/urls.py b/app/dispatch/urls.py new file mode 100644 index 0000000..b5f1761 --- /dev/null +++ b/app/dispatch/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import url +from . import views + + + +urlpatterns = [ + url(r'^$', views.index, name='index'), +] diff --git a/app/dispatch/views.py b/app/dispatch/views.py new file mode 100644 index 0000000..c039614 --- /dev/null +++ b/app/dispatch/views.py @@ -0,0 +1,8 @@ +from django.shortcuts import render +from django.http import HttpResponse + +# Create your views here. + + +def index(request): + return HttpResponse("Hello, world. You're at the index") diff --git a/app/manage.py b/app/manage.py new file mode 100755 index 0000000..7525f87 --- /dev/null +++ b/app/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + 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?" + ) + raise + execute_from_command_line(sys.argv) -- cgit v1.2.3