Initial Commit, basic models/admin pages for CMS_Database tables
This commit is contained in:
commit
090bb9e07a
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
__pycache__/
|
||||||
|
*.sqlite3
|
13
Pipfile
Normal file
13
Pipfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[[source]]
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
name = "pypi"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
django = "*"
|
||||||
|
mysqlclient = "*"
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.9"
|
63
Pipfile.lock
generated
Normal file
63
Pipfile.lock
generated
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"_meta": {
|
||||||
|
"hash": {
|
||||||
|
"sha256": "d1bf637f40b6f55b53eed51857df5d23fab51ea260b3c5b04710b8b94b80f803"
|
||||||
|
},
|
||||||
|
"pipfile-spec": 6,
|
||||||
|
"requires": {
|
||||||
|
"python_version": "3.9"
|
||||||
|
},
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"name": "pypi",
|
||||||
|
"url": "https://pypi.org/simple",
|
||||||
|
"verify_ssl": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"asgiref": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:5ee950735509d04eb673bd7f7120f8fa1c9e2df495394992c73234d526907e17",
|
||||||
|
"sha256:7162a3cb30ab0609f1a4c95938fd73e8604f63bdba516a7f7d64b83ff09478f0"
|
||||||
|
],
|
||||||
|
"markers": "python_version >= '3.5'",
|
||||||
|
"version": "==3.3.1"
|
||||||
|
},
|
||||||
|
"django": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:32ce792ee9b6a0cbbec340123e229ac9f765dff8c2a4ae9247a14b2ba3a365a7",
|
||||||
|
"sha256:baf099db36ad31f970775d0be5587cc58a6256a6771a44eb795b554d45f211b8"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==3.1.7"
|
||||||
|
},
|
||||||
|
"mysqlclient": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:0ac0dd759c4ca02c35a9fedc24bc982cf75171651e8187c2495ec957a87dfff7",
|
||||||
|
"sha256:3381ca1a4f37ff1155fcfde20836b46416d66531add8843f6aa6d968982731c3",
|
||||||
|
"sha256:71c4b330cf2313bbda0307fc858cc9055e64493ba9bf28454d25cf8b3ee8d7f5",
|
||||||
|
"sha256:f6ebea7c008f155baeefe16c56cd3ee6239f7a5a9ae42396c2f1860f08a7c432",
|
||||||
|
"sha256:fc575093cf81b6605bed84653e48b277318b880dc9becf42dd47fa11ffd3e2b6"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==2.0.3"
|
||||||
|
},
|
||||||
|
"pytz": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da",
|
||||||
|
"sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798"
|
||||||
|
],
|
||||||
|
"version": "==2021.1"
|
||||||
|
},
|
||||||
|
"sqlparse": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0",
|
||||||
|
"sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8"
|
||||||
|
],
|
||||||
|
"markers": "python_version >= '3.5'",
|
||||||
|
"version": "==0.4.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"develop": {}
|
||||||
|
}
|
22
manage.py
Executable file
22
manage.py
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/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', 'member_paperwork.settings.dev')
|
||||||
|
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()
|
0
member_paperwork/__init__.py
Normal file
0
member_paperwork/__init__.py
Normal file
16
member_paperwork/asgi.py
Normal file
16
member_paperwork/asgi.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""
|
||||||
|
ASGI config for member_paperwork 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.1/howto/deployment/asgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'member_paperwork.settings')
|
||||||
|
|
||||||
|
application = get_asgi_application()
|
2
member_paperwork/settings/.gitignore
vendored
Normal file
2
member_paperwork/settings/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
dev.py
|
||||||
|
prod.py
|
0
member_paperwork/settings/__init__.py
Normal file
0
member_paperwork/settings/__init__.py
Normal file
92
member_paperwork/settings/base.py
Normal file
92
member_paperwork/settings/base.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
"""
|
||||||
|
Django settings for member_paperwork project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 3.1.7.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/3.1/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/3.1/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'paperwork.apps.PaperworkConfig',
|
||||||
|
]
|
||||||
|
|
||||||
|
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 = 'member_paperwork.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 = 'member_paperwork.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
DATABASE_ROUTERS = ['paperwork.routers.PaperworkRouter']
|
||||||
|
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/3.1/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.1/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.1/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_URL = '/static/'
|
7
member_paperwork/settings/dev_base.py
Normal file
7
member_paperwork/settings/dev_base.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from .base import *
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production
|
||||||
|
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
|
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
|
DEBUG = True
|
21
member_paperwork/urls.py
Normal file
21
member_paperwork/urls.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
"""member_paperwork URL Configuration
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/3.1/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 path
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
]
|
16
member_paperwork/wsgi.py
Normal file
16
member_paperwork/wsgi.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""
|
||||||
|
WSGI config for member_paperwork 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.1/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'member_paperwork.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
0
paperwork/__init__.py
Normal file
0
paperwork/__init__.py
Normal file
32
paperwork/admin.py
Normal file
32
paperwork/admin.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import (CmsRedRiverVeteransScholarship, CertificationDefinition,
|
||||||
|
Certification, InstructorOrVendor, SpecialProgram, Waiver)
|
||||||
|
|
||||||
|
|
||||||
|
class CertificationDefinitionAdmin(admin.ModelAdmin):
|
||||||
|
search_fields = ['certification_name', 'department']
|
||||||
|
|
||||||
|
|
||||||
|
class CertificationAdmin(admin.ModelAdmin):
|
||||||
|
search_fields = ['name', 'certification__certification_name', 'certification__department']
|
||||||
|
|
||||||
|
|
||||||
|
class InstructorOrVendorAdmin(admin.ModelAdmin):
|
||||||
|
search_fields = ['name']
|
||||||
|
|
||||||
|
|
||||||
|
class SpecialProgramAdmin(admin.ModelAdmin):
|
||||||
|
search_fields = ['program_name']
|
||||||
|
|
||||||
|
|
||||||
|
class WaiverAdmin(admin.ModelAdmin):
|
||||||
|
search_fields = ['name']
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(CmsRedRiverVeteransScholarship)
|
||||||
|
admin.site.register(CertificationDefinition, CertificationDefinitionAdmin)
|
||||||
|
admin.site.register(Certification, CertificationAdmin)
|
||||||
|
admin.site.register(InstructorOrVendor, InstructorOrVendorAdmin)
|
||||||
|
admin.site.register(SpecialProgram, SpecialProgramAdmin)
|
||||||
|
admin.site.register(Waiver, WaiverAdmin)
|
5
paperwork/apps.py
Normal file
5
paperwork/apps.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class PaperworkConfig(AppConfig):
|
||||||
|
name = 'paperwork'
|
105
paperwork/models.py
Normal file
105
paperwork/models.py
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class CmsRedRiverVeteransScholarship(models.Model):
|
||||||
|
serial = models.AutoField(primary_key=True)
|
||||||
|
program_name = models.CharField(db_column='Program Name', max_length=255)
|
||||||
|
member_name = models.CharField(db_column='Member Name', max_length=255, blank=True, null=True)
|
||||||
|
discount_percent = models.DecimalField(db_column='Discount Percent', max_digits=16, decimal_places=0, blank=True, null=True)
|
||||||
|
discount_code = models.CharField(db_column='Discount Code', max_length=255, blank=True, null=True)
|
||||||
|
membership_code = models.CharField(db_column='Membership Code', max_length=255, blank=True, null=True)
|
||||||
|
start_date = models.DateField(db_column='Start Date', blank=True, null=True)
|
||||||
|
end_date = models.DateField(db_column='End Date', blank=True, null=True)
|
||||||
|
program_amount = models.DecimalField(db_column='Program Amount', max_digits=16, decimal_places=0, blank=True, null=True)
|
||||||
|
program_status = models.CharField(db_column='Program Status', max_length=16, blank=True, null=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.program_name} {self.member_name}"
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'CMS Red River Veterans Scholarship'
|
||||||
|
|
||||||
|
|
||||||
|
class CertificationDefinition(models.Model):
|
||||||
|
certification_identifier = models.AutoField(db_column='Certification Identifier', primary_key=True)
|
||||||
|
certification_name = models.CharField(db_column='Certification Name', max_length=255, blank=True, null=True)
|
||||||
|
department = models.CharField(db_column='Department', max_length=255, blank=True, null=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.department}: {self.certification_name}"
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'Certification Definitions'
|
||||||
|
|
||||||
|
|
||||||
|
class Certification(models.Model):
|
||||||
|
number = models.AutoField(db_column='Number', primary_key=True)
|
||||||
|
certification = models.ForeignKey(CertificationDefinition, on_delete=models.PROTECT, db_column='Certification')
|
||||||
|
name = models.CharField(db_column='Name', max_length=255)
|
||||||
|
uid = models.CharField(max_length=24, blank=True, null=True)
|
||||||
|
certified_by = models.CharField(db_column='Certified_By', max_length=255, blank=True, null=True)
|
||||||
|
date = models.DateField(db_column='Date', blank=True, null=True)
|
||||||
|
version = models.CharField(db_column='Version', max_length=255, blank=True, null=True)
|
||||||
|
shop_lead_notified = models.DateTimeField(db_column='Shop Lead Notified', blank=True, null=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.name} - {self.certification} [{self.version}]"
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'Certifications'
|
||||||
|
|
||||||
|
|
||||||
|
class InstructorOrVendor(models.Model):
|
||||||
|
serial = models.AutoField(primary_key=True)
|
||||||
|
name = models.CharField(db_column='Name', max_length=255)
|
||||||
|
instructor_agreement_date = models.DateField(db_column='Instructor Agreement Date', blank=True, null=True)
|
||||||
|
w9_date = models.DateField(db_column='W9 date', blank=True, null=True)
|
||||||
|
phone = models.CharField(max_length=255, blank=True, null=True)
|
||||||
|
email_address = models.CharField(db_column='email address', max_length=255, blank=True, null=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.name}"
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'Instructors and Vendors'
|
||||||
|
|
||||||
|
|
||||||
|
class SpecialProgram(models.Model):
|
||||||
|
program_name = models.CharField(db_column='Program Name', primary_key=True, max_length=255)
|
||||||
|
discount_percent = models.DecimalField(db_column='Discount Percent', max_digits=16, decimal_places=0, blank=True, null=True)
|
||||||
|
discount_code = models.CharField(db_column='Discount Code', max_length=255, blank=True, null=True)
|
||||||
|
membership_code = models.CharField(db_column='Membership Code', max_length=255, blank=True, null=True)
|
||||||
|
start_date = models.DateField(db_column='Start Date', blank=True, null=True)
|
||||||
|
end_date = models.DateField(db_column='End Date', blank=True, null=True)
|
||||||
|
program_amount = models.DecimalField(db_column='Program Amount', max_digits=16, decimal_places=0, blank=True, null=True)
|
||||||
|
program_status = models.CharField(db_column='Program Status', max_length=16, blank=True, null=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.program_name
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'Special_Programs'
|
||||||
|
|
||||||
|
|
||||||
|
class Waiver(models.Model):
|
||||||
|
number = models.AutoField(db_column='Number', primary_key=True)
|
||||||
|
name = models.CharField(db_column='Name', max_length=255)
|
||||||
|
date = models.DateField(db_column='Date')
|
||||||
|
emergency_contact_name = models.CharField(db_column='Emergency Contact Name', max_length=255, blank=True, null=True)
|
||||||
|
emergency_contact_number = models.CharField(db_column='Emergency Contact Number', max_length=25, blank=True, null=True)
|
||||||
|
waiver_version = models.CharField(db_column='Waiver version', max_length=64)
|
||||||
|
guardian_name = models.CharField(db_column='Guardian Name', max_length=255, blank=True, null=True)
|
||||||
|
guardian_relation = models.CharField(db_column='Guardian Relation', max_length=255, blank=True, null=True)
|
||||||
|
guardian_date = models.DateField(db_column='Guardian Date', blank=True, null=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.name} {self.date}"
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
managed = False
|
||||||
|
db_table = 'Waivers'
|
21
paperwork/routers.py
Normal file
21
paperwork/routers.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class PaperworkRouter:
|
||||||
|
app_label = 'paperwork'
|
||||||
|
db = 'cms'
|
||||||
|
|
||||||
|
def db_for_read(self, model, **hints):
|
||||||
|
if model._meta.app_label == self.app_label:
|
||||||
|
return self.db
|
||||||
|
return None
|
||||||
|
|
||||||
|
def db_for_write(self, model, **hints):
|
||||||
|
if model._meta.app_label == self.app_label:
|
||||||
|
return self.db
|
||||||
|
return None
|
||||||
|
|
||||||
|
def allow_relation(self, obj1, obj2, **hints):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def allow_migrate(self, db, app_label, model_name=None, **hints):
|
||||||
|
if db == self.db:
|
||||||
|
return False
|
||||||
|
return None
|
3
paperwork/tests.py
Normal file
3
paperwork/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
paperwork/views.py
Normal file
3
paperwork/views.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
Loading…
Reference in New Issue
Block a user