Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove use of settings to point to various models instead of just usi…
Browse files Browse the repository at this point in the history
…ng strings for foriegn keys

the benefits from decoupling did not outweight the loss from code inspection
dpgraham4401 committed Aug 25, 2024
1 parent 2eb8723 commit 06d38d3
Showing 4 changed files with 4 additions and 12 deletions.
6 changes: 0 additions & 6 deletions server/haztrak/settings/base.py
Original file line number Diff line number Diff line change
@@ -256,9 +256,3 @@
"liveness-probe": ["DatabaseBackend"],
},
}

TRAK_ORG_MODEL = "org.Org"
TRAK_RCRAINFO_SITE_MODEL = "rcrasite.RcraSite"
TRAK_MANIFEST_MODEL = "manifest.Manifest"
TRAK_SITE_MODEL = "org.Site"
TRAK_WASTELINE_MODEL = "wasteline.Wasteline"
5 changes: 2 additions & 3 deletions server/manifest/models/handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
from typing import Dict, Optional

from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
from rcrasite.models import RcraSite
@@ -58,7 +57,7 @@ class Meta:
objects = HandlerManager()

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

manifest = models.ForeignKey(
settings.TRAK_MANIFEST_MODEL,
"manifest.Manifest",
related_name="transporters",
on_delete=models.CASCADE,
)
2 changes: 1 addition & 1 deletion server/org/models.py
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ def get_by_epa_id(self: models.Manager, epa_id: str) -> QuerySet:
"""Get a site by RCRAInfo EPA ID number. Throws Site.DoesNotExist if not found."""
return self.filter_by_epa_id(epa_id).get()

def filter_by_org(self: models.Manager, org: settings.TRAK_ORG_MODEL) -> QuerySet:
def filter_by_org(self: models.Manager, org: "Org") -> QuerySet:
"""Get a list of sites by organization"""
return self.filter(org=org)

3 changes: 1 addition & 2 deletions server/wasteline/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
from typing import Optional

from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import gettext_lazy as _
@@ -34,7 +33,7 @@ class Meta:
objects = WasteLineManager()

manifest = models.ForeignKey(
settings.TRAK_MANIFEST_MODEL,
"manifest.Manifest",
related_name="wastes",
on_delete=models.CASCADE,
)

0 comments on commit 06d38d3

Please sign in to comment.