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:
pacnpal
2025-07-04 14:49:36 -04:00
parent 8360f3fd43
commit 751cd86a31
80 changed files with 2943 additions and 2358 deletions

View File

@@ -0,0 +1,107 @@
{% extends "base/base.html" %}
{% load static %}
{% block title %}{{ property_owner.name }} - ThrillWiki{% endblock %}
{% block content %}
<div class="container px-4 mx-auto sm:px-6 lg:px-8">
<!-- Property Owner Header -->
<div class="mb-8">
<h1 class="text-4xl font-bold text-gray-900 dark:text-white mb-4">{{ property_owner.name }}</h1>
{% if property_owner.description %}
<div class="prose dark:prose-invert max-w-none mb-6">
<p class="text-lg text-gray-600 dark:text-gray-400">{{ property_owner.description }}</p>
</div>
{% endif %}
<!-- Property Owner Details -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
{% if property_owner.founded_year %}
<div class="bg-white dark:bg-gray-800 rounded-lg p-4 shadow-sm">
<h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">Founded</h3>
<p class="text-lg font-semibold text-gray-900 dark:text-white">{{ property_owner.founded_year }}</p>
</div>
{% endif %}
{% if property_owner.headquarters %}
<div class="bg-white dark:bg-gray-800 rounded-lg p-4 shadow-sm">
<h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">Headquarters</h3>
<p class="text-lg font-semibold text-gray-900 dark:text-white">{{ property_owner.headquarters }}</p>
</div>
{% endif %}
<div class="bg-white dark:bg-gray-800 rounded-lg p-4 shadow-sm">
<h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">Properties Owned</h3>
<p class="text-lg font-semibold text-gray-900 dark:text-white">{{ owned_parks.count }}</p>
</div>
</div>
</div>
<!-- Owned Properties Section -->
{% if owned_parks %}
<div class="mb-8">
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">Properties Owned</h2>
<div class="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
{% for park in owned_parks %}
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-hidden">
{% if park.main_image %}
<img src="{{ park.main_image.url }}" alt="{{ park.name }}" class="w-full h-48 object-cover">
{% endif %}
<div class="p-6">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white mb-2">
<a href="{% url 'parks:park_detail' park.slug %}" class="hover:text-blue-600 dark:hover:text-blue-400">
{{ park.name }}
</a>
</h3>
{% if park.location_display %}
<p class="text-gray-600 dark:text-gray-400 mb-2">{{ park.location_display }}</p>
{% endif %}
<div class="text-sm text-gray-500 dark:text-gray-500">
{% if park.operator %}
<p class="mb-1">
Operated by:
<a href="{% url 'operators:operator_detail' park.operator.slug %}" class="text-blue-600 dark:text-blue-400 hover:underline">
{{ park.operator.name }}
</a>
</p>
{% endif %}
{% if park.opened_date %}
<p>Opened {{ park.opened_date|date:"Y" }}</p>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% else %}
<div class="mb-8">
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">Properties Owned</h2>
<div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-8 text-center">
<p class="text-gray-500 dark:text-gray-400">No properties currently owned by this company.</p>
</div>
</div>
{% endif %}
<!-- Additional Information -->
{% if property_owner.website %}
<div class="mb-8">
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-4">Links</h2>
<div class="bg-white dark:bg-gray-800 rounded-lg p-6 shadow-sm">
<a href="{{ property_owner.website }}" target="_blank" rel="noopener noreferrer"
class="inline-flex items-center text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300">
Official Website
<svg class="w-4 h-4 ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
</svg>
</a>
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -0,0 +1,63 @@
{% extends "base/base.html" %}
{% load static %}
{% block title %}Property Owners - ThrillWiki{% endblock %}
{% block content %}
<div class="container px-4 mx-auto sm:px-6 lg:px-8">
<!-- Header -->
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900 dark:text-white">Property Owners</h1>
<p class="mt-2 text-gray-600 dark:text-gray-400">Companies that own theme park properties around the world</p>
</div>
<!-- Property Owners List -->
<div class="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
{% for property_owner in property_owners %}
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white mb-2">
<a href="{% url 'property_owners:property_owner_detail' property_owner.slug %}" class="hover:text-blue-600 dark:hover:text-blue-400">
{{ property_owner.name }}
</a>
</h3>
{% if property_owner.description %}
<p class="text-gray-600 dark:text-gray-400 mb-4">{{ property_owner.description|truncatewords:20 }}</p>
{% endif %}
<div class="text-sm text-gray-500 dark:text-gray-500">
{% if property_owner.owned_parks_count %}
<span class="inline-block mr-4">{{ property_owner.owned_parks_count }} propert{{ property_owner.owned_parks_count|pluralize:"y,ies" }}</span>
{% endif %}
{% if property_owner.founded_year %}
<span class="inline-block">Founded {{ property_owner.founded_year }}</span>
{% endif %}
</div>
</div>
{% empty %}
<div class="col-span-full text-center py-12">
<p class="text-gray-500 dark:text-gray-400">No property owners found.</p>
</div>
{% endfor %}
</div>
<!-- Pagination -->
{% if is_paginated %}
<div class="mt-8 flex justify-center">
<nav class="flex space-x-2">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}" class="px-3 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">Previous</a>
{% endif %}
<span class="px-3 py-2 bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded">
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
</span>
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}" class="px-3 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">Next</a>
{% endif %}
</nav>
</div>
{% endif %}
</div>
{% endblock %}