Refactor model imports and update admin classes to use pghistory for historical tracking; replace HistoricalModel with TrackedModel in relevant models

This commit is contained in:
pacnpal
2025-02-09 11:20:40 -05:00
parent 7ecf43f1a4
commit b7f6c60682
24 changed files with 1729 additions and 137 deletions

View File

@@ -1,8 +1,8 @@
from django.db import models
from django.utils.text import slugify
from django.contrib.contenttypes.fields import GenericRelation
from history_tracking.models import HistoricalModel
from history_tracking.models import TrackedModel
import pghistory
# Shared choices that will be used by multiple models
CATEGORY_CHOICES = [
@@ -15,8 +15,8 @@ CATEGORY_CHOICES = [
('OT', 'Other'),
]
class RideModel(HistoricalModel):
@pghistory.track()
class RideModel(TrackedModel):
"""
Represents a specific model/type of ride that can be manufactured by different companies.
For example: B&M Dive Coaster, Vekoma Boomerang, etc.
@@ -46,8 +46,8 @@ class RideModel(HistoricalModel):
def __str__(self) -> str:
return self.name if not self.manufacturer else f"{self.manufacturer.name} {self.name}"
class Ride(HistoricalModel):
@pghistory.track()
class Ride(TrackedModel):
STATUS_CHOICES = [
('OPERATING', 'Operating'),
('SBNO', 'Standing But Not Operating'),
@@ -91,7 +91,7 @@ class Ride(HistoricalModel):
blank=True
)
designer = models.ForeignKey(
'companies.Designer',
'designers.Designer', # Updated to point to the new Designer model
on_delete=models.SET_NULL,
related_name='rides',
null=True,
@@ -147,7 +147,6 @@ class Ride(HistoricalModel):
self.slug = slugify(self.name)
super().save(*args, **kwargs)
class RollerCoasterStats(models.Model):
TRACK_MATERIAL_CHOICES = [
('STEEL', 'Steel'),