mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-22 11:11:10 -05:00
feat: Complete Company Migration Project and Fix Autocomplete Issues
- Implemented a comprehensive migration from a single Company model to specialized entities (Operators, PropertyOwners, Manufacturers, Designers). - Resolved critical issues in search suggestions that were returning 404 errors by fixing database queries and reordering URL patterns. - Conducted extensive testing and validation of the new entity relationships, ensuring all core functionality is operational. - Updated test suite to reflect changes in entity structure, including renaming fields from `owner` to `operator`. - Addressed display issues in the user interface related to operator and manufacturer information. - Completed migration cleanup, fixing references to the removed `companies` app across migration files and test configurations. - Established a stable testing environment with successful test database creation and functional test infrastructure.
This commit is contained in:
@@ -134,7 +134,7 @@ class ParkFilter(LocationFilterMixin, RatingFilterMixin, DateRangeFilterMixin, F
|
||||
|
||||
self._qs = base_qs
|
||||
for name, value in self.form.cleaned_data.items():
|
||||
if value in [None, '', 0] and name not in ['has_owner']:
|
||||
if value in [None, '', 0] and name not in ['has_operator']:
|
||||
continue
|
||||
self._qs = self.filters[name].filter(self._qs, value)
|
||||
self._qs = self._qs.distinct()
|
||||
|
||||
@@ -67,7 +67,7 @@ class Migration(migrations.Migration):
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="parks",
|
||||
to="companies.company",
|
||||
to="operators.operator",
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -7,7 +7,7 @@ def get_base_park_queryset() -> QuerySet[Park]:
|
||||
|
||||
park_type = ContentType.objects.get_for_model(Park)
|
||||
return (
|
||||
Park.objects.select_related('owner')
|
||||
Park.objects.select_related('operator', 'property_owner')
|
||||
.prefetch_related(
|
||||
'photos',
|
||||
'rides',
|
||||
|
||||
@@ -55,7 +55,7 @@ class ParkFilterTests(TestCase):
|
||||
name="Family Fun Park",
|
||||
description="Family-friendly entertainment and attractions",
|
||||
status="CLOSED_TEMP",
|
||||
owner=cls.operator2,
|
||||
operator=cls.operator2,
|
||||
opening_date=date(2015, 6, 15),
|
||||
size_acres=50,
|
||||
ride_count=15,
|
||||
@@ -190,25 +190,25 @@ class ParkFilterTests(TestCase):
|
||||
f"Filter should be invalid for data: {invalid_data}"
|
||||
)
|
||||
|
||||
def test_company_filtering(self):
|
||||
"""Test company/owner filtering"""
|
||||
# Test specific company
|
||||
queryset = ParkFilter(data={"operator": str(self.operator1.id)}).qs
|
||||
def test_operator_filtering(self):
|
||||
"""Test operator filtering"""
|
||||
# Test specific operator
|
||||
queryset = ParkFilter(data={"operator": str(self.operator1.pk)}).qs
|
||||
self.assertEqual(queryset.count(), 1)
|
||||
self.assertIn(self.park1, queryset)
|
||||
|
||||
# Test other company
|
||||
queryset = ParkFilter(data={"operator": str(self.operator2.id)}).qs
|
||||
# Test other operator
|
||||
queryset = ParkFilter(data={"operator": str(self.operator2.pk)}).qs
|
||||
self.assertEqual(queryset.count(), 1)
|
||||
self.assertIn(self.park2, queryset)
|
||||
|
||||
# Test parks without owner
|
||||
queryset = ParkFilter(data={"has_owner": False}).qs
|
||||
# Test parks without operator
|
||||
queryset = ParkFilter(data={"has_operator": False}).qs
|
||||
self.assertEqual(queryset.count(), 1)
|
||||
self.assertIn(self.park3, queryset)
|
||||
|
||||
# Test parks with any owner
|
||||
queryset = ParkFilter(data={"has_owner": True}).qs
|
||||
# Test parks with any operator
|
||||
queryset = ParkFilter(data={"has_operator": True}).qs
|
||||
self.assertEqual(queryset.count(), 2)
|
||||
self.assertIn(self.park1, queryset)
|
||||
self.assertIn(self.park2, queryset)
|
||||
@@ -217,7 +217,7 @@ class ParkFilterTests(TestCase):
|
||||
queryset = ParkFilter(data={}).qs
|
||||
self.assertEqual(queryset.count(), 3)
|
||||
|
||||
# Test invalid company ID
|
||||
# Test invalid operator ID
|
||||
queryset = ParkFilter(data={"operator": "99999"}).qs
|
||||
self.assertEqual(queryset.count(), 0)
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class ParkModelTests(TestCase):
|
||||
name="Test Park",
|
||||
description="A test park",
|
||||
status="OPERATING",
|
||||
owner=self.operator
|
||||
operator=self.operator
|
||||
)
|
||||
|
||||
# Create location for the park
|
||||
|
||||
Reference in New Issue
Block a user