mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-23 02:31:08 -05:00
Add operators and property owners functionality
- Implemented OperatorListView and OperatorDetailView for managing operators. - Created corresponding templates for operator listing and detail views. - Added PropertyOwnerListView and PropertyOwnerDetailView for managing property owners. - Developed templates for property owner listing and detail views. - Established relationships between parks and operators, and parks and property owners in the models. - Created migrations to reflect the new relationships and fields in the database. - Added admin interfaces for PropertyOwner management. - Implemented tests for operators and property owners.
This commit is contained in:
@@ -9,19 +9,19 @@ from datetime import date, timedelta
|
||||
|
||||
from parks.models import Park
|
||||
from parks.filters import ParkFilter
|
||||
from companies.models import Company
|
||||
from operators.models import Operator
|
||||
from location.models import Location
|
||||
|
||||
class ParkFilterTests(TestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
"""Set up test data for all filter tests"""
|
||||
# Create companies
|
||||
cls.company1 = Company.objects.create(
|
||||
# Create operators
|
||||
cls.operator1 = Operator.objects.create(
|
||||
name="Thrilling Adventures Inc",
|
||||
slug="thrilling-adventures"
|
||||
)
|
||||
cls.company2 = Company.objects.create(
|
||||
cls.operator2 = Operator.objects.create(
|
||||
name="Family Fun Corp",
|
||||
slug="family-fun"
|
||||
)
|
||||
@@ -31,7 +31,7 @@ class ParkFilterTests(TestCase):
|
||||
name="Thrilling Adventures Park",
|
||||
description="A thrilling park with lots of roller coasters",
|
||||
status="OPERATING",
|
||||
owner=cls.company1,
|
||||
operator=cls.operator1,
|
||||
opening_date=date(2020, 1, 1),
|
||||
size_acres=100,
|
||||
ride_count=20,
|
||||
@@ -55,7 +55,7 @@ class ParkFilterTests(TestCase):
|
||||
name="Family Fun Park",
|
||||
description="Family-friendly entertainment and attractions",
|
||||
status="CLOSED_TEMP",
|
||||
owner=cls.company2,
|
||||
owner=cls.operator2,
|
||||
opening_date=date(2015, 6, 15),
|
||||
size_acres=50,
|
||||
ride_count=15,
|
||||
@@ -193,12 +193,12 @@ class ParkFilterTests(TestCase):
|
||||
def test_company_filtering(self):
|
||||
"""Test company/owner filtering"""
|
||||
# Test specific company
|
||||
queryset = ParkFilter(data={"owner": str(self.company1.id)}).qs
|
||||
queryset = ParkFilter(data={"operator": str(self.operator1.id)}).qs
|
||||
self.assertEqual(queryset.count(), 1)
|
||||
self.assertIn(self.park1, queryset)
|
||||
|
||||
# Test other company
|
||||
queryset = ParkFilter(data={"owner": str(self.company2.id)}).qs
|
||||
queryset = ParkFilter(data={"operator": str(self.operator2.id)}).qs
|
||||
self.assertEqual(queryset.count(), 1)
|
||||
self.assertIn(self.park2, queryset)
|
||||
|
||||
@@ -218,7 +218,7 @@ class ParkFilterTests(TestCase):
|
||||
self.assertEqual(queryset.count(), 3)
|
||||
|
||||
# Test invalid company ID
|
||||
queryset = ParkFilter(data={"owner": "99999"}).qs
|
||||
queryset = ParkFilter(data={"operator": "99999"}).qs
|
||||
self.assertEqual(queryset.count(), 0)
|
||||
|
||||
def test_numeric_filtering(self):
|
||||
|
||||
@@ -9,13 +9,13 @@ from django.utils import timezone
|
||||
from datetime import date
|
||||
|
||||
from parks.models import Park, ParkArea
|
||||
from companies.models import Company
|
||||
from operators.models import Operator
|
||||
from location.models import Location
|
||||
|
||||
class ParkModelTests(TestCase):
|
||||
def setUp(self):
|
||||
"""Set up test data"""
|
||||
self.company = Company.objects.create(
|
||||
self.operator = Operator.objects.create(
|
||||
name="Test Company",
|
||||
slug="test-company"
|
||||
)
|
||||
@@ -25,7 +25,7 @@ class ParkModelTests(TestCase):
|
||||
name="Test Park",
|
||||
description="A test park",
|
||||
status="OPERATING",
|
||||
owner=self.company
|
||||
owner=self.operator
|
||||
)
|
||||
|
||||
# Create location for the park
|
||||
@@ -47,7 +47,7 @@ class ParkModelTests(TestCase):
|
||||
self.assertEqual(self.park.name, "Test Park")
|
||||
self.assertEqual(self.park.slug, "test-park")
|
||||
self.assertEqual(self.park.status, "OPERATING")
|
||||
self.assertEqual(self.park.owner, self.company)
|
||||
self.assertEqual(self.park.operator, self.operator)
|
||||
|
||||
def test_slug_generation(self):
|
||||
"""Test automatic slug generation"""
|
||||
|
||||
Reference in New Issue
Block a user