feat: Implement initial schema and add various API, service, and management command enhancements across the application.

This commit is contained in:
pacnpal
2026-01-01 15:13:01 -05:00
parent c95f99ca10
commit b243b17af7
413 changed files with 11164 additions and 17433 deletions

View File

@@ -24,17 +24,11 @@ class Company(TrackedModel):
website = models.URLField(blank=True, help_text="Company website URL")
# General company info
founded_date = models.DateField(
null=True, blank=True, help_text="Date the company was founded"
)
founded_date = models.DateField(null=True, blank=True, help_text="Date the company was founded")
# Manufacturer-specific fields
rides_count = models.IntegerField(
default=0, help_text="Number of rides manufactured (auto-calculated)"
)
coasters_count = models.IntegerField(
default=0, help_text="Number of coasters manufactured (auto-calculated)"
)
rides_count = models.IntegerField(default=0, help_text="Number of rides manufactured (auto-calculated)")
coasters_count = models.IntegerField(default=0, help_text="Number of coasters manufactured (auto-calculated)")
# Frontend URL
url = models.URLField(blank=True, help_text="Frontend URL for this company")
@@ -50,9 +44,7 @@ class Company(TrackedModel):
# CRITICAL: Only MANUFACTURER and DESIGNER are for rides domain
# OPERATOR and PROPERTY_OWNER are for parks domain and handled separately
if self.roles:
frontend_domain = getattr(
settings, "FRONTEND_DOMAIN", "https://thrillwiki.com"
)
frontend_domain = getattr(settings, "FRONTEND_DOMAIN", "https://thrillwiki.com")
primary_role = self.roles[0] # Use first role as primary
if primary_role == "MANUFACTURER":
@@ -76,12 +68,9 @@ class Company(TrackedModel):
# Check pghistory first
try:
from django.apps import apps
history_model = apps.get_model('rides', f'{cls.__name__}Event')
history_entry = (
history_model.objects.filter(slug=slug)
.order_by("-pgh_created_at")
.first()
)
history_model = apps.get_model("rides", f"{cls.__name__}Event")
history_entry = history_model.objects.filter(slug=slug).order_by("-pgh_created_at").first()
if history_entry:
return cls.objects.get(id=history_entry.pgh_obj_id), True
except LookupError:
@@ -90,12 +79,10 @@ class Company(TrackedModel):
# Check manual slug history as fallback
try:
historical = HistoricalSlug.objects.get(
content_type__model="company", slug=slug
)
historical = HistoricalSlug.objects.get(content_type__model="company", slug=slug)
return cls.objects.get(pk=historical.object_id), True
except (HistoricalSlug.DoesNotExist, cls.DoesNotExist):
raise cls.DoesNotExist("No company found with this slug")
raise cls.DoesNotExist("No company found with this slug") from None
class Meta(TrackedModel.Meta):
app_label = "rides"