Skip to content

Commit

Permalink
Use settings to piece together apps instead of hard coded foreign key…
Browse files Browse the repository at this point in the history
…s, remove dead code (ImportInfo and CorrectionInfo)

    use settings.AUTH_USER_MODEL instead of explicitly using the core user model

    Add new settings including TRAK_RCRAINFO_SITE_MODEL, TRAK_SITE_MODEL, TRAK_HANDLER_MODEL, TRAK_ORG_MODEL, TRAK_MANIFEST_MODEL
  • Loading branch information
dpgraham4401 committed Feb 20, 2024
1 parent db6fb53 commit e333f9f
Show file tree
Hide file tree
Showing 23 changed files with 6,430 additions and 207 deletions.
2 changes: 1 addition & 1 deletion server/apps/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-02-17 19:30
# Generated by Django 4.2.10 on 2024-02-17 21:09

import django.contrib.auth.models
import django.contrib.auth.validators
Expand Down
2 changes: 1 addition & 1 deletion server/apps/handler/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-02-17 19:30
# Generated by Django 4.2.10 on 2024-02-17 21:09

import apps.handler.models.contact_models
from django.db import migrations, models
Expand Down
2 changes: 1 addition & 1 deletion server/apps/handler/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-02-17 19:30
# Generated by Django 4.2.10 on 2024-02-17 21:09

from django.db import migrations, models
import django.db.models.deletion
Expand Down
5 changes: 3 additions & 2 deletions server/apps/handler/models/handler_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.db import models

from apps.rcrasite.models import RcraSite
from haztrak import settings

from . import ManifestPhone
from .base_models import TrakBaseManager, TrakBaseModel
Expand Down Expand Up @@ -60,7 +61,7 @@ class Meta:
objects = HandlerManager()

rcra_site = models.ForeignKey(
"rcrasite.RcraSite",
settings.TRAK_RCRAINFO_SITE_MODEL,
on_delete=models.CASCADE,
help_text="Hazardous waste rcra_site associated with the manifest",
)
Expand Down Expand Up @@ -134,7 +135,7 @@ class Meta:
objects = TransporterManager()

manifest = models.ForeignKey(
"manifest.Manifest",
settings.TRAK_MANIFEST_MODEL,
related_name="transporters",
on_delete=models.CASCADE,
)
Expand Down
3 changes: 2 additions & 1 deletion server/apps/handler/models/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.db import models

from apps.handler.models.base_models import TrakBaseManager, TrakBaseModel
from haztrak import settings

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -106,7 +107,7 @@ class Meta:
objects = ESignatureManager()

manifest_handler = models.ForeignKey(
"handler.Handler",
settings.TRAK_HANDLER_MODEL,
related_name="e_signatures",
on_delete=models.CASCADE,
)
Expand Down
30 changes: 1 addition & 29 deletions server/apps/manifest/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-02-17 19:30
# Generated by Django 4.2.10 on 2024-02-17 21:09

import apps.manifest.models
from django.db import migrations, models
Expand Down Expand Up @@ -29,22 +29,6 @@ class Migration(migrations.Migration):
'verbose_name_plural': 'Additional Info',
},
),
migrations.CreateModel(
name='CorrectionInfo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('version_number', models.IntegerField(blank=True, null=True)),
('active', models.BooleanField(blank=True, null=True)),
('ppc_active', models.BooleanField(blank=True, null=True)),
('epa_site_id', models.CharField(blank=True, max_length=100, null=True)),
('initiator_role', models.CharField(blank=True, choices=[('IN', 'Industry'), ('PP', 'Ppc'), ('EP', 'Epa'), ('ST', 'State')], max_length=2, null=True)),
('update_role', models.CharField(blank=True, choices=[('IN', 'Industry'), ('PP', 'Ppc'), ('EP', 'Epa'), ('ST', 'State')], max_length=2, null=True)),
],
options={
'verbose_name': 'Correction Info',
'verbose_name_plural': 'Correction Info',
},
),
migrations.CreateModel(
name='PortOfEntry',
fields=[
Expand Down Expand Up @@ -101,16 +85,4 @@ class Migration(migrations.Migration):
'ordering': ['update_date', 'mtn'],
},
),
migrations.CreateModel(
name='ImportInfo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('import_generator', models.JSONField(blank=True, null=True)),
('port_of_entry', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='manifest.portofentry')),
],
options={
'verbose_name': 'Import Info',
'verbose_name_plural': 'Import Info',
},
),
]
76 changes: 4 additions & 72 deletions server/apps/manifest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from django.utils.translation import gettext_lazy as _

from apps.handler.models import Handler, Transporter
from apps.rcrasite.models import RcraSiteType, RcraStates, Role
from apps.rcrasite.models import RcraSiteType, RcraStates
from apps.wasteline.models import WasteLine
from haztrak import settings

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -198,13 +199,13 @@ class Status(models.TextChoices):
blank=True,
)
generator = models.ForeignKey(
"handler.Handler",
settings.TRAK_HANDLER_MODEL,
on_delete=models.PROTECT,
related_name="generator",
)
# transporters
tsdf = models.ForeignKey(
"handler.Handler",
settings.TRAK_HANDLER_MODEL,
verbose_name="designated facility",
on_delete=models.PROTECT,
related_name="designated_facility",
Expand Down Expand Up @@ -388,72 +389,3 @@ class Meta:
null=True,
blank=True,
)


class ImportInfo(models.Model):
"""
Contains information on hazardous waste imported to the United Stated
"""

class Meta:
verbose_name = "Import Info"
verbose_name_plural = "Import Info"

import_generator = models.JSONField(
null=True,
blank=True,
)
port_of_entry = models.ForeignKey(
"PortOfEntry",
on_delete=models.PROTECT,
null=True,
blank=True,
)


class CorrectionInfo(models.Model):
"""
Contains correction information.
Shall not be provided for Save and Update Manifest services.
will be returned by Get manifest service
"""

class Meta:
verbose_name = "Correction Info"
verbose_name_plural = "Correction Info"

version_number = models.IntegerField(
null=True,
blank=True,
)
active = models.BooleanField(
null=True,
blank=True,
)
ppc_active = models.BooleanField(
null=True,
blank=True,
)
# electronic_signature_info = models.ForeignKey(
# "ESignature",
# on_delete=models.PROTECT,
# null=True,
# blank=True,
# )
epa_site_id = models.CharField(
max_length=100,
null=True,
blank=True,
)
initiator_role = models.CharField(
choices=Role.choices,
max_length=2,
null=True,
blank=True,
)
update_role = models.CharField(
choices=Role.choices,
max_length=2,
null=True,
blank=True,
)
83 changes: 1 addition & 82 deletions server/apps/manifest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@
from rest_framework import serializers

from apps.handler.serializers import (
ESignatureSerializer,
HandlerSerializer,
TransporterSerializer,
)
from apps.manifest.models import (
AdditionalInfo,
CorrectionInfo,
ImportInfo,
Manifest,
PortOfEntry,
draft_mtn,
)
from apps.rcrasite.models import RcraStates, Role
from apps.rcrasite.models import RcraStates
from apps.wasteline.serializers import (
WasteLineSerializer,
)
Expand Down Expand Up @@ -304,81 +301,3 @@ class PortOfEntrySerializer(TrakBaseSerializer):
class Meta:
model = PortOfEntry
fields = ["state", "cityPort"]


class ImportInfoSerializer(TrakBaseSerializer):
"""
Serializer for import information
"""

importGenerator = serializers.JSONField(
source="import_generator",
allow_null=True,
required=False,
)
portOfEntry = PortOfEntrySerializer(
source="port_of_entry",
required=False,
allow_null=True,
)

class Meta:
model = ImportInfo
fields = ["importGenerator", "PortOfEntry"]


class CorrectionInfoSerializer(TrakBaseSerializer):
"""
Serializer for Correction Info
"""

versionNumber = serializers.CharField(
source="version_number",
required=False,
allow_null=True,
)
active = serializers.BooleanField(
required=False,
allow_null=True,
default=False,
)
ppcActive = serializers.BooleanField(
source="ppc_active",
required=False,
allow_null=True,
default=False,
)
electronicSignatureInfo = ESignatureSerializer(
source="electronic_signature_info",
required=False,
allow_null=True,
)
epaSiteId = serializers.CharField(
source="epa_site_id",
required=False,
allow_null=True,
)
initiatorRole = serializers.ChoiceField(
source="initiator_role",
choices=Role.choices,
required=False,
allow_null=True,
)
updateRole = serializers.ChoiceField(
source="update_role",
choices=Role.choices,
required=False,
allow_null=True,
)

class Meta:
model = CorrectionInfo
fields = [
"versionNumber",
"active",
"ppcActive",
"electronicSignatureInfo",
"epaSiteId",
"initiatorRole",
"updateRole",
]
2 changes: 1 addition & 1 deletion server/apps/org/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-02-17 19:30
# Generated by Django 4.2.10 on 2024-02-17 21:09

from django.conf import settings
from django.db import migrations, models
Expand Down
5 changes: 3 additions & 2 deletions server/apps/org/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.db import models

from apps.profile.models import RcrainfoProfile
from haztrak import settings


class TrakOrg(models.Model):
Expand All @@ -24,7 +25,7 @@ class Meta:
default=uuid.uuid4,
)
admin = models.ForeignKey(
"core.TrakUser",
settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
null=True,
blank=True,
Expand Down Expand Up @@ -67,7 +68,7 @@ class Meta:
blank=True,
)
user = models.OneToOneField(
"core.TrakUser",
settings.AUTH_USER_MODEL,
related_name="org_permissions",
on_delete=models.CASCADE,
null=True,
Expand Down
2 changes: 1 addition & 1 deletion server/apps/profile/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-02-17 19:30
# Generated by Django 4.2.10 on 2024-02-17 21:09

from django.conf import settings
from django.db import migrations, models
Expand Down
2 changes: 1 addition & 1 deletion server/apps/rcrasite/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-02-17 19:30
# Generated by Django 4.2.10 on 2024-02-17 21:09

import apps.rcrasite.models.contact_models
from django.db import migrations, models
Expand Down
6 changes: 1 addition & 5 deletions server/apps/rcrasite/serializers/profile_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,9 @@ class RcrainfoSitePermissionsSerializer(RcraSitePermissionSerializer):
"WIETS",
"SiteManagement",
]
siteId = serializers.StringRelatedField(
siteId = serializers.CharField(
source="site",
)
name = serializers.StringRelatedField(
source="site.rcra_site.name",
required=False,
)
SiteManagement = RcraPermissionField(
source="site_manager",
)
Expand Down
6 changes: 3 additions & 3 deletions server/apps/site/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-02-17 19:30
# Generated by Django 4.2.10 on 2024-02-17 21:09

from django.conf import settings
import django.core.validators
Expand All @@ -11,9 +11,9 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('org', '0001_initial'),
('rcrasite', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('rcrasite', '0001_initial'),
('org', '0001_initial'),
]

operations = [
Expand Down
Loading

0 comments on commit e333f9f

Please sign in to comment.