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

View File

@ -11,6 +11,6 @@ import os
from django.core.asgi import get_asgi_application 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() application = get_asgi_application()

View File

@ -22,58 +22,60 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', "django.contrib.admin",
'django.contrib.auth', "django.contrib.auth",
'django.contrib.contenttypes', "django.contrib.contenttypes",
'django.contrib.sessions', "django.contrib.sessions",
'django.contrib.messages', "django.contrib.messages",
'django.contrib.staticfiles', "django.contrib.staticfiles",
'django_admin_logs', "django_admin_logs",
'membershipworks.apps.MembershipworksConfig', "membershipworks.apps.MembershipworksConfig",
'paperwork.apps.PaperworkConfig', "paperwork.apps.PaperworkConfig",
] ]
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', "django.middleware.security.SecurityMiddleware",
'django.contrib.sessions.middleware.SessionMiddleware', "django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.common.CommonMiddleware', "django.middleware.common.CommonMiddleware",
'django.middleware.csrf.CsrfViewMiddleware', "django.middleware.csrf.CsrfViewMiddleware",
'django.contrib.auth.middleware.AuthenticationMiddleware', "django.contrib.auth.middleware.AuthenticationMiddleware",
'django.contrib.messages.middleware.MessageMiddleware', "django.contrib.messages.middleware.MessageMiddleware",
'django.middleware.clickjacking.XFrameOptionsMiddleware', "django.middleware.clickjacking.XFrameOptionsMiddleware",
] ]
ROOT_URLCONF = 'member_paperwork.urls' ROOT_URLCONF = "member_paperwork.urls"
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', "BACKEND": "django.template.backends.django.DjangoTemplates",
'DIRS': [], "DIRS": [],
'APP_DIRS': True, "APP_DIRS": True,
'OPTIONS': { "OPTIONS": {
'context_processors': [ "context_processors": [
'django.template.context_processors.debug', "django.template.context_processors.debug",
'django.template.context_processors.request', "django.template.context_processors.request",
'django.contrib.auth.context_processors.auth', "django.contrib.auth.context_processors.auth",
'django.contrib.messages.context_processors.messages', "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', DATABASE_ROUTERS = [
'paperwork.routers.PaperworkRouter'] "membershipworks.routers.MembershipWorksRouter",
"paperwork.routers.PaperworkRouter",
]
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/ # https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = "en-us"
TIME_ZONE = 'UTC' TIME_ZONE = "UTC"
USE_I18N = True USE_I18N = True
USE_L10N = True USE_L10N = True
USE_TZ = True USE_TZ = True
@ -82,4 +84,4 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/ # 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 # "AUTH_LDAP_SERVER_URI", "AUTH_LDAP_BIND_DN", and "AUTH_LDAP_BIND_PASSWORD" set in prod.py
AUTHENTICATION_BACKENDS = [ AUTHENTICATION_BACKENDS = [
'django_auth_ldap.backend.LDAPBackend', "django_auth_ldap.backend.LDAPBackend",
'django.contrib.auth.backends.ModelBackend', "django.contrib.auth.backends.ModelBackend",
] ]
AUTH_LDAP_USER_SEARCH = LDAPSearch( AUTH_LDAP_USER_SEARCH = LDAPSearch(
'cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org', "cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org",
ldap.SCOPE_SUBTREE, ldap.SCOPE_SUBTREE,
'(uid=%(user)s)', "(uid=%(user)s)",
) )
AUTH_LDAP_USER_ATTR_MAP = { AUTH_LDAP_USER_ATTR_MAP = {
'first_name': 'givenName', "first_name": "givenName",
'last_name': 'sn', "last_name": "sn",
'email': 'mail', "email": "mail",
} }
AUTH_LDAP_USER_FLAGS_BY_GROUP = { AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_staff": LDAPGroupQuery( "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( AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
'cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org', "cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org",
ldap.SCOPE_SUBTREE, ldap.SCOPE_SUBTREE,
'(objectClass=posixGroup)', "(objectClass=posixGroup)",
) )
AUTH_LDAP_GROUP_TYPE = PosixGroupType() AUTH_LDAP_GROUP_TYPE = PosixGroupType()
AUTH_LDAP_MIRROR_GROUPS = True AUTH_LDAP_MIRROR_GROUPS = True

View File

@ -17,5 +17,5 @@ from django.contrib import admin
from django.urls import path from django.urls import path
urlpatterns = [ 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 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() application = get_wsgi_application()

View File

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

View File

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

View File

@ -9,11 +9,11 @@ class Flag(models.Model):
type = models.CharField(max_length=6) type = models.CharField(max_length=6)
def __str__(self): def __str__(self):
return f'{self.name} ({self.type})' return f"{self.name} ({self.type})"
class Meta: class Meta:
managed = False managed = False
db_table = 'flag' db_table = "flag"
# TODO: is this still a temporal table? # 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) closet_storage = models.TextField(db_column="Closet Storage #", null=True)
storage_shelf = models.TextField(db_column="Storage Shelf #", 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( access_permitted_shops_during_extended_hours = models.BooleanField(
db_column="Access Permitted Shops During Extended Hours?" 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) audit_date = models.DateField(db_column="Audit Date", null=True)
agreement_version = models.TextField(db_column="Agreement Version", null=True) agreement_version = models.TextField(db_column="Agreement Version", null=True)
paperwork_status = models.TextField(db_column="Paperwork status", 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( membership_agreement_acknowledgement_page_filled_out = models.BooleanField(
db_column="Membership Agreement Acknowledgement Page Filled Out" db_column="Membership Agreement Acknowledgement Page Filled Out"
) )
membership_agreement_signed = models.BooleanField( membership_agreement_signed = models.BooleanField(
db_column="Membership Agreement Signed" 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( self_certify_essential_business = models.BooleanField(
db_column="selfCertifyEssentialBusiness" db_column="selfCertifyEssentialBusiness"
) )
accepted_covid19_policy = models.BooleanField(db_column="Accepted COVID-19 Policy") 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): def __str__(self):
return f"{self.account_name}" return f"{self.account_name}"
class Meta: class Meta:
managed = False managed = False
db_table = 'members' db_table = "members"
ordering = ('first_name', 'last_name') ordering = ("first_name", "last_name")
class MemberFlag(models.Model): class MemberFlag(models.Model):
@ -137,12 +142,13 @@ class MemberFlag(models.Model):
flag = models.ForeignKey(Flag, on_delete=models.PROTECT) flag = models.ForeignKey(Flag, on_delete=models.PROTECT)
def __str__(self): def __str__(self):
return f'{self.member} - {self.flag}' return f"{self.member} - {self.flag}"
class Meta: class Meta:
managed = False managed = False
db_table = 'memberflag' db_table = "memberflag"
constraints = [ 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: class MembershipWorksRouter:
app_label = 'membershipworks' app_label = "membershipworks"
db = 'membershipworks' db = "membershipworks"
def db_for_read(self, model, **hints): def db_for_read(self, model, **hints):
if model._meta.app_label == self.app_label: if model._meta.app_label == self.app_label:

View File

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

View File

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

View File

@ -12,97 +12,312 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='CertificationDefinition', name="CertificationDefinition",
fields=[ 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)), "certification_identifier",
('department', models.CharField(blank=True, db_column='Department', max_length=255, null=True)), 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={ options={
'db_table': 'Certification Definitions', "db_table": "Certification Definitions",
'ordering': ('certification_name', 'department'), "ordering": ("certification_name", "department"),
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='CmsRedRiverVeteransScholarship', name="CmsRedRiverVeteransScholarship",
fields=[ fields=[
('serial', models.AutoField(primary_key=True, serialize=False)), ("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)), "program_name",
('discount_percent', models.DecimalField(blank=True, db_column='Discount Percent', decimal_places=0, max_digits=16, null=True)), models.CharField(db_column="Program Name", max_length=255),
('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)), "member_name",
('end_date', models.DateField(blank=True, db_column='End Date', null=True)), models.CharField(
('program_amount', models.DecimalField(blank=True, db_column='Program Amount', decimal_places=0, max_digits=16, null=True)), blank=True, db_column="Member Name", max_length=255, null=True
('program_status', models.CharField(blank=True, db_column='Program Status', max_length=16, 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={ options={
'db_table': 'CMS Red River Veterans Scholarship', "db_table": "CMS Red River Veterans Scholarship",
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='InstructorOrVendor', name="InstructorOrVendor",
fields=[ fields=[
('serial', models.AutoField(primary_key=True, serialize=False)), ("serial", models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(db_column='Name', max_length=255)), ("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)), "instructor_agreement_date",
('phone', models.CharField(blank=True, max_length=255, null=True)), models.DateField(
('email_address', models.CharField(blank=True, db_column='email address', max_length=255, null=True)), 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={ options={
'db_table': 'Instructors and Vendors', "db_table": "Instructors and Vendors",
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='SpecialProgram', name="SpecialProgram",
fields=[ 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)), "program_name",
('discount_code', models.CharField(blank=True, db_column='Discount Code', max_length=255, null=True)), models.CharField(
('membership_code', models.CharField(blank=True, db_column='Membership Code', max_length=255, null=True)), db_column="Program Name",
('start_date', models.DateField(blank=True, db_column='Start Date', null=True)), max_length=255,
('end_date', models.DateField(blank=True, db_column='End Date', null=True)), primary_key=True,
('program_amount', models.DecimalField(blank=True, db_column='Program Amount', decimal_places=0, max_digits=16, null=True)), serialize=False,
('program_status', models.CharField(blank=True, db_column='Program Status', max_length=16, 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={ options={
'db_table': 'Special_Programs', "db_table": "Special_Programs",
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='Waiver', name="Waiver",
fields=[ fields=[
('number', models.AutoField(db_column='Number', primary_key=True, serialize=False)), (
('name', models.CharField(db_column='Name', max_length=255)), "number",
('date', models.DateField(db_column='Date')), models.AutoField(
('emergency_contact_name', models.CharField(blank=True, db_column='Emergency Contact Name', max_length=255, null=True)), db_column="Number", primary_key=True, serialize=False
('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)), ("name", models.CharField(db_column="Name", max_length=255)),
('guardian_relation', models.CharField(blank=True, db_column='Guardian Relation', max_length=255, null=True)), ("date", models.DateField(db_column="Date")),
('guardian_date', models.DateField(blank=True, db_column='Guardian Date', null=True)), (
"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={ options={
'db_table': 'Waivers', "db_table": "Waivers",
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='Certification', name="Certification",
fields=[ fields=[
('number', models.AutoField(db_column='Number', primary_key=True, serialize=False)), (
('name', models.CharField(db_column='Name', max_length=255)), "number",
('certified_by', models.CharField(blank=True, db_column='Certified_By', max_length=255, null=True)), models.AutoField(
('date', models.DateField(blank=True, db_column='Date', null=True)), db_column="Number", primary_key=True, serialize=False
('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')), ("name", models.CharField(db_column="Name", max_length=255)),
('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)), "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={ 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): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('membershipworks', '0001_initial'), ("membershipworks", "0001_initial"),
('paperwork', '0001_initial'), ("paperwork", "0001_initial"),
] ]
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='CertificationVersion', name="CertificationVersion",
fields=[ 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)), "id",
('definition', models.ForeignKey(db_column='Certification', on_delete=django.db.models.deletion.PROTECT, to='paperwork.certificationdefinition')), 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( migrations.AddConstraint(
model_name='certificationversion', model_name="certificationversion",
constraint=models.UniqueConstraint(fields=('definition', 'version'), name='unique_certification_version'), constraint=models.UniqueConstraint(
fields=("definition", "version"), name="unique_certification_version"
),
), ),
migrations.AddField( migrations.AddField(
model_name='certification', model_name="certification",
name='certification_version', name="certification_version",
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='paperwork.certificationversion', null=True), field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to="paperwork.certificationversion",
null=True,
),
), ),
migrations.RunPython(migrate_certification_version_forward), migrations.RunPython(migrate_certification_version_forward),
migrations.AlterField( migrations.AlterField(
model_name='certification', model_name="certification",
name='certification_version', name="certification_version",
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='paperwork.certificationversion'), field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
to="paperwork.certificationversion",
),
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='certification', model_name="certification",
name='certification', name="certification",
), ),
migrations.RemoveField( migrations.RemoveField(
model_name='certification', model_name="certification",
name='version', name="version",
), ),
] ]

View File

@ -5,39 +5,69 @@ from membershipworks.models import Member
class CmsRedRiverVeteransScholarship(models.Model): class CmsRedRiverVeteransScholarship(models.Model):
serial = models.AutoField(primary_key=True) serial = models.AutoField(primary_key=True)
program_name = models.CharField(db_column='Program Name', max_length=255) 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) member_name = models.CharField(
discount_percent = models.DecimalField(db_column='Discount Percent', max_digits=16, decimal_places=0, blank=True, null=True) db_column="Member Name", max_length=255, 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) discount_percent = models.DecimalField(
start_date = models.DateField(db_column='Start Date', blank=True, null=True) db_column="Discount Percent",
end_date = models.DateField(db_column='End Date', blank=True, null=True) max_digits=16,
program_amount = models.DecimalField(db_column='Program Amount', max_digits=16, decimal_places=0, blank=True, null=True) decimal_places=0,
program_status = models.CharField(db_column='Program Status', max_length=16, blank=True, null=True) 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): def __str__(self):
return f"{self.program_name} {self.member_name}" return f"{self.program_name} {self.member_name}"
class Meta: class Meta:
db_table = 'CMS Red River Veterans Scholarship' db_table = "CMS Red River Veterans Scholarship"
class CertificationDefinition(models.Model): class CertificationDefinition(models.Model):
certification_identifier = models.AutoField(db_column='Certification Identifier', primary_key=True) certification_identifier = models.AutoField(
certification_name = models.CharField(db_column='Certification Name', max_length=255, blank=True, null=True) db_column="Certification Identifier", primary_key=True
department = models.CharField(db_column='Department', max_length=255, blank=True, null=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): def __str__(self):
return f"{self.certification_name} <{self.department}>" return f"{self.certification_name} <{self.department}>"
class Meta: class Meta:
db_table = 'Certification Definitions' db_table = "Certification Definitions"
ordering = ('certification_name', 'department') ordering = ("certification_name", "department")
class CertificationVersion(models.Model): class CertificationVersion(models.Model):
definition = models.ForeignKey(CertificationDefinition, on_delete=models.PROTECT, db_column='Certification') definition = models.ForeignKey(
version = models.CharField(db_column='Version', max_length=255, blank=True, null=True) CertificationDefinition, on_delete=models.PROTECT, db_column="Certification"
)
version = models.CharField(
db_column="Version", max_length=255, blank=True, null=True
)
def __str__(self): def __str__(self):
return f"{self.definition} [{self.version}]" return f"{self.definition} [{self.version}]"
@ -51,67 +81,113 @@ class CertificationVersion(models.Model):
class Certification(models.Model): class Certification(models.Model):
number = models.AutoField(db_column='Number', primary_key=True) number = models.AutoField(db_column="Number", primary_key=True)
certification_version = models.ForeignKey(CertificationVersion, on_delete=models.PROTECT) certification_version = models.ForeignKey(
name = models.CharField(db_column='Name', max_length=255) CertificationVersion, on_delete=models.PROTECT
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) name = models.CharField(db_column="Name", max_length=255)
date = models.DateField(db_column='Date', blank=True, null=True) member = models.ForeignKey(
shop_lead_notified = models.DateTimeField(db_column='Shop Lead Notified', blank=True, null=True) Member,
notes = models.CharField(db_column='Notes', max_length=255, blank=True, null=True) 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): def __str__(self):
return f"{self.name} - {self.certification_version}" return f"{self.name} - {self.certification_version}"
class Meta: class Meta:
db_table = 'Certifications' db_table = "Certifications"
class InstructorOrVendor(models.Model): class InstructorOrVendor(models.Model):
serial = models.AutoField(primary_key=True) serial = models.AutoField(primary_key=True)
name = models.CharField(db_column='Name', max_length=255) name = models.CharField(db_column="Name", max_length=255)
instructor_agreement_date = models.DateField(db_column='Instructor Agreement Date', blank=True, null=True) instructor_agreement_date = models.DateField(
w9_date = models.DateField(db_column='W9 date', blank=True, null=True) 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) 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): def __str__(self):
return f"{self.name}" return f"{self.name}"
class Meta: class Meta:
db_table = 'Instructors and Vendors' db_table = "Instructors and Vendors"
class SpecialProgram(models.Model): class SpecialProgram(models.Model):
program_name = models.CharField(db_column='Program Name', primary_key=True, max_length=255) program_name = models.CharField(
discount_percent = models.DecimalField(db_column='Discount Percent', max_digits=16, decimal_places=0, blank=True, null=True) db_column="Program Name", primary_key=True, max_length=255
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) discount_percent = models.DecimalField(
start_date = models.DateField(db_column='Start Date', blank=True, null=True) db_column="Discount Percent",
end_date = models.DateField(db_column='End Date', blank=True, null=True) max_digits=16,
program_amount = models.DecimalField(db_column='Program Amount', max_digits=16, decimal_places=0, blank=True, null=True) decimal_places=0,
program_status = models.CharField(db_column='Program Status', max_length=16, blank=True, null=True) 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): def __str__(self):
return self.program_name return self.program_name
class Meta: class Meta:
db_table = 'Special_Programs' db_table = "Special_Programs"
class Waiver(models.Model): class Waiver(models.Model):
number = models.AutoField(db_column='Number', primary_key=True) number = models.AutoField(db_column="Number", primary_key=True)
name = models.CharField(db_column='Name', max_length=255) name = models.CharField(db_column="Name", max_length=255)
date = models.DateField(db_column='Date') 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_name = models.CharField(
emergency_contact_number = models.CharField(db_column='Emergency Contact Number', max_length=25, blank=True, null=True) db_column="Emergency Contact Name", max_length=255, 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) emergency_contact_number = models.CharField(
guardian_relation = models.CharField(db_column='Guardian Relation', max_length=255, blank=True, null=True) db_column="Emergency Contact Number", max_length=25, blank=True, null=True
guardian_date = models.DateField(db_column='Guardian Date', 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): def __str__(self):
return f"{self.name} {self.date}" return f"{self.name} {self.date}"
class Meta: class Meta:
db_table = 'Waivers' db_table = "Waivers"

View File

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

1
pyproject.toml Normal file
View File

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