Add/apply black formatter

This commit is contained in:
Adam Goldsmith 2022-02-11 13:48:47 -05:00
parent d50cec383e
commit 35f714760d
17 changed files with 577 additions and 232 deletions

View File

@ -6,7 +6,7 @@ import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'member_paperwork.settings.dev')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "member_paperwork.settings.dev")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
@ -18,5 +18,5 @@ def main():
execute_from_command_line(sys.argv)
if __name__ == '__main__':
if __name__ == "__main__":
main()

View File

@ -11,6 +11,6 @@ import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'member_paperwork.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "member_paperwork.settings")
application = get_asgi_application()

View File

@ -22,58 +22,60 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_admin_logs',
'membershipworks.apps.MembershipworksConfig',
'paperwork.apps.PaperworkConfig',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_admin_logs",
"membershipworks.apps.MembershipworksConfig",
"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',
"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'
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',
"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'
WSGI_APPLICATION = "member_paperwork.wsgi.application"
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
DATABASE_ROUTERS = ['membershipworks.routers.MembershipWorksRouter',
'paperwork.routers.PaperworkRouter']
DATABASE_ROUTERS = [
"membershipworks.routers.MembershipWorksRouter",
"paperwork.routers.PaperworkRouter",
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
@ -82,4 +84,4 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_URL = "/static/"

View File

@ -11,31 +11,32 @@ DEBUG = False
# "AUTH_LDAP_SERVER_URI", "AUTH_LDAP_BIND_DN", and "AUTH_LDAP_BIND_PASSWORD" set in prod.py
AUTHENTICATION_BACKENDS = [
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
"django_auth_ldap.backend.LDAPBackend",
"django.contrib.auth.backends.ModelBackend",
]
AUTH_LDAP_USER_SEARCH = LDAPSearch(
'cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org',
"cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org",
ldap.SCOPE_SUBTREE,
'(uid=%(user)s)',
"(uid=%(user)s)",
)
AUTH_LDAP_USER_ATTR_MAP = {
'first_name': 'givenName',
'last_name': 'sn',
'email': 'mail',
"first_name": "givenName",
"last_name": "sn",
"email": "mail",
}
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_staff": LDAPGroupQuery(
"cn=MW_CMS Staff,cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org"),
"cn=MW_CMS Staff,cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org"
),
}
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
'cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org',
"cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org",
ldap.SCOPE_SUBTREE,
'(objectClass=posixGroup)',
"(objectClass=posixGroup)",
)
AUTH_LDAP_GROUP_TYPE = PosixGroupType()
AUTH_LDAP_MIRROR_GROUPS = True

View File

@ -17,5 +17,5 @@ from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
path("admin/", admin.site.urls),
]

View File

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'member_paperwork.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "member_paperwork.settings")
application = get_wsgi_application()

View File

@ -20,7 +20,7 @@ class MemberFlagInline(admin.TabularInline):
@admin.register(Member)
class MemberAdmin(ReadOnlyAdmin):
search_fields = ['account_name']
search_fields = ["account_name"]
inlines = [MemberFlagInline]

View File

@ -2,5 +2,5 @@ from django.apps import AppConfig
class MembershipworksConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'membershipworks'
default_auto_field = "django.db.models.BigAutoField"
name = "membershipworks"

View File

@ -9,11 +9,11 @@ class Flag(models.Model):
type = models.CharField(max_length=6)
def __str__(self):
return f'{self.name} ({self.type})'
return f"{self.name} ({self.type})"
class Meta:
managed = False
db_table = 'flag'
db_table = "flag"
# TODO: is this still a temporal table?
@ -47,7 +47,9 @@ class Member(models.Model):
)
closet_storage = models.TextField(db_column="Closet Storage #", null=True)
storage_shelf = models.TextField(db_column="Storage Shelf #", null=True)
personal_studio_space = models.TextField(db_column="Personal Studio Space #", null=True)
personal_studio_space = models.TextField(
db_column="Personal Studio Space #", null=True
)
access_permitted_shops_during_extended_hours = models.BooleanField(
db_column="Access Permitted Shops During Extended Hours?"
)
@ -108,28 +110,31 @@ class Member(models.Model):
audit_date = models.DateField(db_column="Audit Date", null=True)
agreement_version = models.TextField(db_column="Agreement Version", null=True)
paperwork_status = models.TextField(db_column="Paperwork status", null=True)
membership_agreement_dated = models.BooleanField(db_column="Membership agreement dated")
membership_agreement_dated = models.BooleanField(
db_column="Membership agreement dated"
)
membership_agreement_acknowledgement_page_filled_out = models.BooleanField(
db_column="Membership Agreement Acknowledgement Page Filled Out"
)
membership_agreement_signed = models.BooleanField(
db_column="Membership Agreement Signed"
)
liability_form_filled_out = models.BooleanField(db_column="Liability Form Filled Out")
liability_form_filled_out = models.BooleanField(
db_column="Liability Form Filled Out"
)
self_certify_essential_business = models.BooleanField(
db_column="selfCertifyEssentialBusiness"
)
accepted_covid19_policy = models.BooleanField(db_column="Accepted COVID-19 Policy")
flags = models.ManyToManyField(Flag, through='MemberFlag', related_name='members')
flags = models.ManyToManyField(Flag, through="MemberFlag", related_name="members")
def __str__(self):
return f"{self.account_name}"
class Meta:
managed = False
db_table = 'members'
ordering = ('first_name', 'last_name')
db_table = "members"
ordering = ("first_name", "last_name")
class MemberFlag(models.Model):
@ -137,12 +142,13 @@ class MemberFlag(models.Model):
flag = models.ForeignKey(Flag, on_delete=models.PROTECT)
def __str__(self):
return f'{self.member} - {self.flag}'
return f"{self.member} - {self.flag}"
class Meta:
managed = False
db_table = 'memberflag'
db_table = "memberflag"
constraints = [
models.UniqueConstraint(fields=['member', 'flag_id'], name='unique_member_flag')
models.UniqueConstraint(
fields=["member", "flag_id"], name="unique_member_flag"
)
]

View File

@ -1,6 +1,6 @@
class MembershipWorksRouter:
app_label = 'membershipworks'
db = 'membershipworks'
app_label = "membershipworks"
db = "membershipworks"
def db_for_read(self, model, **hints):
if model._meta.app_label == self.app_label:

View File

@ -1,9 +1,14 @@
from django.contrib import admin
from .models import (CmsRedRiverVeteransScholarship,
CertificationDefinition, Certification,
from .models import (
CmsRedRiverVeteransScholarship,
CertificationDefinition,
Certification,
CertificationVersion,
InstructorOrVendor, SpecialProgram, Waiver)
InstructorOrVendor,
SpecialProgram,
Waiver,
)
class CertificationVersionInline(admin.TabularInline):
@ -13,73 +18,81 @@ class CertificationVersionInline(admin.TabularInline):
@admin.register(CertificationVersion)
class CertificationVersionAdmin(admin.ModelAdmin):
search_fields = ['definition__certification_name', 'version']
list_display = ['definition', 'version']
list_filter = ['definition__department', 'definition__certification_name']
search_fields = ["definition__certification_name", "version"]
list_display = ["definition", "version"]
list_filter = ["definition__department", "definition__certification_name"]
@admin.register(CertificationDefinition)
class CertificationDefinitionAdmin(admin.ModelAdmin):
search_fields = ['certification_name']
list_display = ['certification_name', 'department']
list_filter = ['department']
search_fields = ["certification_name"]
list_display = ["certification_name", "department"]
list_filter = ["department"]
inlines = [CertificationVersionInline]
@admin.register(Certification)
class CertificationAdmin(admin.ModelAdmin):
search_fields = ['name', 'certification__certification_name', 'certification__department']
autocomplete_fields = ['member']
exclude = ['shop_lead_notified']
search_fields = [
"name",
"certification__certification_name",
"certification__department",
]
autocomplete_fields = ["member"]
exclude = ["shop_lead_notified"]
@admin.display(description='Certification Name',
ordering='certification_version__definition__certification_name')
@admin.display(
description="Certification Name",
ordering="certification_version__definition__certification_name",
)
def certification_name(self, obj):
return obj.certification_version.definition.certification_name
@admin.display(description='Certification Version',
ordering='certification_version__version')
@admin.display(
description="Certification Version", ordering="certification_version__version"
)
def certification_version_version(self, obj):
return obj.certification_version.version
@admin.display(description='Department',
ordering='certification_version__definition__department')
@admin.display(
description="Department",
ordering="certification_version__definition__department",
)
def certification_department(self, obj):
return obj.certification_version.definition.department
list_display = [
'certification_name',
'name',
'certification_version_version',
'certification_department',
'date',
'shop_lead_notified',
'certified_by',
"certification_name",
"name",
"certification_version_version",
"certification_department",
"date",
"shop_lead_notified",
"certified_by",
]
list_display_links = [
'certification_name',
'name',
"certification_name",
"name",
]
list_filter = [
'certification_version__definition__department',
('shop_lead_notified', admin.EmptyFieldListFilter),
"certification_version__definition__department",
("shop_lead_notified", admin.EmptyFieldListFilter),
]
@admin.register(InstructorOrVendor)
class InstructorOrVendorAdmin(admin.ModelAdmin):
search_fields = ['name']
search_fields = ["name"]
@admin.register(SpecialProgram)
class SpecialProgramAdmin(admin.ModelAdmin):
search_fields = ['program_name']
search_fields = ["program_name"]
@admin.register(Waiver)
class WaiverAdmin(admin.ModelAdmin):
search_fields = ['name']
search_fields = ["name"]
admin.site.register(CmsRedRiverVeteransScholarship)

View File

@ -2,4 +2,4 @@ from django.apps import AppConfig
class PaperworkConfig(AppConfig):
name = 'paperwork'
name = "paperwork"

View File

@ -12,97 +12,312 @@ class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
name='CertificationDefinition',
name="CertificationDefinition",
fields=[
('certification_identifier', models.AutoField(db_column='Certification Identifier', primary_key=True, serialize=False)),
('certification_name', models.CharField(blank=True, db_column='Certification Name', max_length=255, null=True)),
('department', models.CharField(blank=True, db_column='Department', max_length=255, null=True)),
(
"certification_identifier",
models.AutoField(
db_column="Certification Identifier",
primary_key=True,
serialize=False,
),
),
(
"certification_name",
models.CharField(
blank=True,
db_column="Certification Name",
max_length=255,
null=True,
),
),
(
"department",
models.CharField(
blank=True, db_column="Department", max_length=255, null=True
),
),
],
options={
'db_table': 'Certification Definitions',
'ordering': ('certification_name', 'department'),
"db_table": "Certification Definitions",
"ordering": ("certification_name", "department"),
},
),
migrations.CreateModel(
name='CmsRedRiverVeteransScholarship',
name="CmsRedRiverVeteransScholarship",
fields=[
('serial', models.AutoField(primary_key=True, serialize=False)),
('program_name', models.CharField(db_column='Program Name', max_length=255)),
('member_name', models.CharField(blank=True, db_column='Member Name', max_length=255, null=True)),
('discount_percent', models.DecimalField(blank=True, db_column='Discount Percent', decimal_places=0, max_digits=16, null=True)),
('discount_code', models.CharField(blank=True, db_column='Discount Code', max_length=255, null=True)),
('membership_code', models.CharField(blank=True, db_column='Membership Code', max_length=255, null=True)),
('start_date', models.DateField(blank=True, db_column='Start Date', null=True)),
('end_date', models.DateField(blank=True, db_column='End Date', null=True)),
('program_amount', models.DecimalField(blank=True, db_column='Program Amount', decimal_places=0, max_digits=16, null=True)),
('program_status', models.CharField(blank=True, db_column='Program Status', max_length=16, null=True)),
("serial", models.AutoField(primary_key=True, serialize=False)),
(
"program_name",
models.CharField(db_column="Program Name", max_length=255),
),
(
"member_name",
models.CharField(
blank=True, db_column="Member Name", max_length=255, null=True
),
),
(
"discount_percent",
models.DecimalField(
blank=True,
db_column="Discount Percent",
decimal_places=0,
max_digits=16,
null=True,
),
),
(
"discount_code",
models.CharField(
blank=True, db_column="Discount Code", max_length=255, null=True
),
),
(
"membership_code",
models.CharField(
blank=True,
db_column="Membership Code",
max_length=255,
null=True,
),
),
(
"start_date",
models.DateField(blank=True, db_column="Start Date", null=True),
),
(
"end_date",
models.DateField(blank=True, db_column="End Date", null=True),
),
(
"program_amount",
models.DecimalField(
blank=True,
db_column="Program Amount",
decimal_places=0,
max_digits=16,
null=True,
),
),
(
"program_status",
models.CharField(
blank=True, db_column="Program Status", max_length=16, null=True
),
),
],
options={
'db_table': 'CMS Red River Veterans Scholarship',
"db_table": "CMS Red River Veterans Scholarship",
},
),
migrations.CreateModel(
name='InstructorOrVendor',
name="InstructorOrVendor",
fields=[
('serial', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(db_column='Name', max_length=255)),
('instructor_agreement_date', models.DateField(blank=True, db_column='Instructor Agreement Date', null=True)),
('w9_date', models.DateField(blank=True, db_column='W9 date', null=True)),
('phone', models.CharField(blank=True, max_length=255, null=True)),
('email_address', models.CharField(blank=True, db_column='email address', max_length=255, null=True)),
("serial", models.AutoField(primary_key=True, serialize=False)),
("name", models.CharField(db_column="Name", max_length=255)),
(
"instructor_agreement_date",
models.DateField(
blank=True, db_column="Instructor Agreement Date", null=True
),
),
(
"w9_date",
models.DateField(blank=True, db_column="W9 date", null=True),
),
("phone", models.CharField(blank=True, max_length=255, null=True)),
(
"email_address",
models.CharField(
blank=True, db_column="email address", max_length=255, null=True
),
),
],
options={
'db_table': 'Instructors and Vendors',
"db_table": "Instructors and Vendors",
},
),
migrations.CreateModel(
name='SpecialProgram',
name="SpecialProgram",
fields=[
('program_name', models.CharField(db_column='Program Name', max_length=255, primary_key=True, serialize=False)),
('discount_percent', models.DecimalField(blank=True, db_column='Discount Percent', decimal_places=0, max_digits=16, null=True)),
('discount_code', models.CharField(blank=True, db_column='Discount Code', max_length=255, null=True)),
('membership_code', models.CharField(blank=True, db_column='Membership Code', max_length=255, null=True)),
('start_date', models.DateField(blank=True, db_column='Start Date', null=True)),
('end_date', models.DateField(blank=True, db_column='End Date', null=True)),
('program_amount', models.DecimalField(blank=True, db_column='Program Amount', decimal_places=0, max_digits=16, null=True)),
('program_status', models.CharField(blank=True, db_column='Program Status', max_length=16, null=True)),
(
"program_name",
models.CharField(
db_column="Program Name",
max_length=255,
primary_key=True,
serialize=False,
),
),
(
"discount_percent",
models.DecimalField(
blank=True,
db_column="Discount Percent",
decimal_places=0,
max_digits=16,
null=True,
),
),
(
"discount_code",
models.CharField(
blank=True, db_column="Discount Code", max_length=255, null=True
),
),
(
"membership_code",
models.CharField(
blank=True,
db_column="Membership Code",
max_length=255,
null=True,
),
),
(
"start_date",
models.DateField(blank=True, db_column="Start Date", null=True),
),
(
"end_date",
models.DateField(blank=True, db_column="End Date", null=True),
),
(
"program_amount",
models.DecimalField(
blank=True,
db_column="Program Amount",
decimal_places=0,
max_digits=16,
null=True,
),
),
(
"program_status",
models.CharField(
blank=True, db_column="Program Status", max_length=16, null=True
),
),
],
options={
'db_table': 'Special_Programs',
"db_table": "Special_Programs",
},
),
migrations.CreateModel(
name='Waiver',
name="Waiver",
fields=[
('number', models.AutoField(db_column='Number', primary_key=True, serialize=False)),
('name', models.CharField(db_column='Name', max_length=255)),
('date', models.DateField(db_column='Date')),
('emergency_contact_name', models.CharField(blank=True, db_column='Emergency Contact Name', max_length=255, null=True)),
('emergency_contact_number', models.CharField(blank=True, db_column='Emergency Contact Number', max_length=25, null=True)),
('waiver_version', models.CharField(db_column='Waiver version', max_length=64)),
('guardian_name', models.CharField(blank=True, db_column='Guardian Name', max_length=255, null=True)),
('guardian_relation', models.CharField(blank=True, db_column='Guardian Relation', max_length=255, null=True)),
('guardian_date', models.DateField(blank=True, db_column='Guardian Date', null=True)),
(
"number",
models.AutoField(
db_column="Number", primary_key=True, serialize=False
),
),
("name", models.CharField(db_column="Name", max_length=255)),
("date", models.DateField(db_column="Date")),
(
"emergency_contact_name",
models.CharField(
blank=True,
db_column="Emergency Contact Name",
max_length=255,
null=True,
),
),
(
"emergency_contact_number",
models.CharField(
blank=True,
db_column="Emergency Contact Number",
max_length=25,
null=True,
),
),
(
"waiver_version",
models.CharField(db_column="Waiver version", max_length=64),
),
(
"guardian_name",
models.CharField(
blank=True, db_column="Guardian Name", max_length=255, null=True
),
),
(
"guardian_relation",
models.CharField(
blank=True,
db_column="Guardian Relation",
max_length=255,
null=True,
),
),
(
"guardian_date",
models.DateField(blank=True, db_column="Guardian Date", null=True),
),
],
options={
'db_table': 'Waivers',
"db_table": "Waivers",
},
),
migrations.CreateModel(
name='Certification',
name="Certification",
fields=[
('number', models.AutoField(db_column='Number', primary_key=True, serialize=False)),
('name', models.CharField(db_column='Name', max_length=255)),
('certified_by', models.CharField(blank=True, db_column='Certified_By', max_length=255, null=True)),
('date', models.DateField(blank=True, db_column='Date', null=True)),
('version', models.CharField(blank=True, db_column='Version', max_length=255, null=True)),
('shop_lead_notified', models.DateTimeField(blank=True, db_column='Shop Lead Notified', null=True)),
('certification', models.ForeignKey(db_column='Certification', on_delete=django.db.models.deletion.PROTECT, to='paperwork.certificationdefinition')),
('member', models.ForeignKey(blank=True, db_column='uid', db_constraint=False, null=True, on_delete=django.db.models.deletion.PROTECT, to='membershipworks.member')),
('notes', models.CharField(blank=True, db_column='Notes', max_length=255, null=True)),
(
"number",
models.AutoField(
db_column="Number", primary_key=True, serialize=False
),
),
("name", models.CharField(db_column="Name", max_length=255)),
(
"certified_by",
models.CharField(
blank=True, db_column="Certified_By", max_length=255, null=True
),
),
("date", models.DateField(blank=True, db_column="Date", null=True)),
(
"version",
models.CharField(
blank=True, db_column="Version", max_length=255, null=True
),
),
(
"shop_lead_notified",
models.DateTimeField(
blank=True, db_column="Shop Lead Notified", null=True
),
),
(
"certification",
models.ForeignKey(
db_column="Certification",
on_delete=django.db.models.deletion.PROTECT,
to="paperwork.certificationdefinition",
),
),
(
"member",
models.ForeignKey(
blank=True,
db_column="uid",
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="membershipworks.member",
),
),
(
"notes",
models.CharField(
blank=True, db_column="Notes", max_length=255, null=True
),
),
],
options={
'db_table': 'Certifications',
"db_table": "Certifications",
},
),
]

View File

@ -21,40 +21,69 @@ def migrate_certification_version_forward(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
('membershipworks', '0001_initial'),
('paperwork', '0001_initial'),
("membershipworks", "0001_initial"),
("paperwork", "0001_initial"),
]
operations = [
migrations.CreateModel(
name='CertificationVersion',
name="CertificationVersion",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('version', models.CharField(blank=True, db_column='Version', max_length=255, null=True)),
('definition', models.ForeignKey(db_column='Certification', on_delete=django.db.models.deletion.PROTECT, to='paperwork.certificationdefinition')),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"version",
models.CharField(
blank=True, db_column="Version", max_length=255, null=True
),
),
(
"definition",
models.ForeignKey(
db_column="Certification",
on_delete=django.db.models.deletion.PROTECT,
to="paperwork.certificationdefinition",
),
),
],
),
migrations.AddConstraint(
model_name='certificationversion',
constraint=models.UniqueConstraint(fields=('definition', 'version'), name='unique_certification_version'),
model_name="certificationversion",
constraint=models.UniqueConstraint(
fields=("definition", "version"), name="unique_certification_version"
),
),
migrations.AddField(
model_name='certification',
name='certification_version',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='paperwork.certificationversion', null=True),
model_name="certification",
name="certification_version",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to="paperwork.certificationversion",
null=True,
),
),
migrations.RunPython(migrate_certification_version_forward),
migrations.AlterField(
model_name='certification',
name='certification_version',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='paperwork.certificationversion'),
model_name="certification",
name="certification_version",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to="paperwork.certificationversion",
),
),
migrations.RemoveField(
model_name='certification',
name='certification',
model_name="certification",
name="certification",
),
migrations.RemoveField(
model_name='certification',
name='version',
model_name="certification",
name="version",
),
]

View File

@ -5,39 +5,69 @@ from membershipworks.models import Member
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)
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:
db_table = 'CMS Red River Veterans Scholarship'
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)
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.certification_name} <{self.department}>"
class Meta:
db_table = 'Certification Definitions'
ordering = ('certification_name', 'department')
db_table = "Certification Definitions"
ordering = ("certification_name", "department")
class CertificationVersion(models.Model):
definition = models.ForeignKey(CertificationDefinition, on_delete=models.PROTECT, db_column='Certification')
version = models.CharField(db_column='Version', max_length=255, blank=True, null=True)
definition = models.ForeignKey(
CertificationDefinition, on_delete=models.PROTECT, db_column="Certification"
)
version = models.CharField(
db_column="Version", max_length=255, blank=True, null=True
)
def __str__(self):
return f"{self.definition} [{self.version}]"
@ -51,67 +81,113 @@ class CertificationVersion(models.Model):
class Certification(models.Model):
number = models.AutoField(db_column='Number', primary_key=True)
certification_version = models.ForeignKey(CertificationVersion, on_delete=models.PROTECT)
name = models.CharField(db_column='Name', max_length=255)
member = models.ForeignKey(Member, on_delete=models.PROTECT, to_field='uid', db_column='uid', blank=True, null=True, db_constraint=False)
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)
shop_lead_notified = models.DateTimeField(db_column='Shop Lead Notified', blank=True, null=True)
notes = models.CharField(db_column='Notes', max_length=255, blank=True, null=True)
number = models.AutoField(db_column="Number", primary_key=True)
certification_version = models.ForeignKey(
CertificationVersion, on_delete=models.PROTECT
)
name = models.CharField(db_column="Name", max_length=255)
member = models.ForeignKey(
Member,
on_delete=models.PROTECT,
to_field="uid",
db_column="uid",
blank=True,
null=True,
db_constraint=False,
)
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)
shop_lead_notified = models.DateTimeField(
db_column="Shop Lead Notified", blank=True, null=True
)
notes = models.CharField(db_column="Notes", max_length=255, blank=True, null=True)
def __str__(self):
return f"{self.name} - {self.certification_version}"
class Meta:
db_table = 'Certifications'
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)
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)
email_address = models.CharField(
db_column="email address", max_length=255, blank=True, null=True
)
def __str__(self):
return f"{self.name}"
class Meta:
db_table = 'Instructors and Vendors'
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)
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:
db_table = 'Special_Programs'
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)
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:
db_table = 'Waivers'
db_table = "Waivers"

View File

@ -1,7 +1,7 @@
class PaperworkRouter:
app_label = 'paperwork'
related_app_labels = {'paperwork', 'membershipworks'}
db = 'cms'
app_label = "paperwork"
related_app_labels = {"paperwork", "membershipworks"}
db = "cms"
def db_for_read(self, model, **hints):
if model._meta.app_label == self.app_label:
@ -14,7 +14,9 @@ class PaperworkRouter:
return None
def allow_relation(self, obj1, obj2, **hints):
if obj1._meta.app_label in self.related_app_labels or \
obj2._meta.app_label in self.related_app_labels:
if (
obj1._meta.app_label in self.related_app_labels
or obj2._meta.app_label in self.related_app_labels
):
return True
return None

1
pyproject.toml Normal file
View File

@ -0,0 +1 @@
[tool.black]