weird header stuff

This commit is contained in:
pacnpal
2024-11-03 22:03:56 +00:00
parent ed585e6a56
commit 07526dcba8
34 changed files with 5047 additions and 185 deletions

View File

@@ -7,14 +7,20 @@ class HistoryTrackingConfig(AppConfig):
name = "history_tracking"
def ready(self):
from django.apps import apps
from .mixins import HistoricalChangeMixin
from .models import Park
models_with_history = [Park]
for model in models_with_history:
# Check if mixin is already applied
if HistoricalChangeMixin not in model.history.model.__bases__:
model.history.model.__bases__ = (
HistoricalChangeMixin,
) + model.history.model.__bases__
# Get the Park model
try:
Park = apps.get_model('parks', 'Park')
ParkArea = apps.get_model('parks', 'ParkArea')
# Apply mixin to historical models
if HistoricalChangeMixin not in Park.history.model.__bases__:
Park.history.model.__bases__ = (HistoricalChangeMixin,) + Park.history.model.__bases__
if HistoricalChangeMixin not in ParkArea.history.model.__bases__:
ParkArea.history.model.__bases__ = (HistoricalChangeMixin,) + ParkArea.history.model.__bases__
except LookupError:
# Models might not be loaded yet
pass