mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-02 03:27:02 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user