Skip to content

Commit 689f40c

Browse files
committed
minor changes: django.conf.settings over dojo.settings
1 parent 95ca9db commit 689f40c

4 files changed

Lines changed: 8 additions & 42 deletions

File tree

dojo/apps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22

33
from django.apps import AppConfig
4+
from django.conf import settings
45
from django.core.checks import register as register_check
56
from django.db import models
67
from watson import search as watson
@@ -16,6 +17,12 @@ class DojoAppConfig(AppConfig):
1617
verbose_name = "Defect Dojo"
1718

1819
def ready(self):
20+
if settings.ENABLE_AUDITLOG:
21+
from auditlog.registry import auditlog # noqa: PLC0415 raised: AppRegistryNotReady
22+
23+
from dojo.location.models import Location # noqa: PLC0415 raised: AppRegistryNotReady
24+
25+
auditlog.register(Location)
1926
# we need to initializer waston here because in models.py is to early if we want add extra fields to index
2027
# logger.info('ready(): initializing watson')
2128
# commented out ^ as it prints in manage.py dumpdata, docker logs and many other places

dojo/location/models.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from typing import TYPE_CHECKING, Self, TypeVar
44

5-
from auditlog.registry import auditlog
65
from django.db import transaction
76
from django.db.models import (
87
CASCADE,
@@ -34,7 +33,6 @@
3433
)
3534
from dojo.location.status import FindingLocationStatus, ProductLocationStatus
3635
from dojo.models import Dojo_User, Finding, Product, _manage_inherited_tags, copy_model_util
37-
from dojo.settings import settings
3836
from dojo.tools.locations import LocationAssociationData
3937

4038
if TYPE_CHECKING:
@@ -454,7 +452,3 @@ class Meta:
454452
def __str__(self) -> str:
455453
"""Return the string representation of a LocationProductReference."""
456454
return f"{self.location} - Product: {self.product} ({self.status})"
457-
458-
459-
if settings.ENABLE_AUDITLOG:
460-
auditlog.register(Location)

dojo/reports/widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from collections import OrderedDict
44

55
from django import forms
6+
from django.conf import settings
67
from django.forms import Widget
78
from django.forms.utils import flatatt
89
from django.http import QueryDict
@@ -23,7 +24,6 @@
2324
from dojo.location.status import FindingLocationStatus
2425
from dojo.models import Endpoint, Finding
2526
from dojo.reports.queries import prefetch_related_endpoints_for_report, prefetch_related_findings_for_report
26-
from dojo.settings import settings
2727
from dojo.url.filters import URLFilter
2828
from dojo.utils import get_page_items, get_system_setting, get_words_for_field
2929

wsgi.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)