Files
thrillwiki_django_no_react/templates/parks/park_detail.html
2024-11-03 20:21:39 +00:00

264 lines
14 KiB
HTML

{% extends "base/base.html" %}
{% load static %}
{% block title %}{{ park.name }} - ThrillWiki{% endblock %}
{% block content %}
<div class="container px-4 mx-auto">
<!-- Header with Quick Facts -->
<div class="p-6 mb-6 bg-white rounded-lg shadow dark:bg-gray-800">
<div class="flex flex-col lg:flex-row lg:items-start lg:justify-between">
<div class="mb-6 lg:mb-0 lg:mr-6 lg:flex-1">
<div class="flex items-start justify-between">
<div>
<h1 class="mb-2 text-3xl font-bold text-gray-900 dark:text-white">{{ park.name }}</h1>
{% if park.city or park.state or park.country %}
{% spaceless %}
<p class="mb-2 text-gray-600 dark:text-gray-400">
<i class="mr-1 fas fa-map-marker-alt"></i> {% if park.city %}{{ park.city }}{% endif %}{% if park.city and park.state %}, {% endif %}{% if park.state %}{{ park.state }}{% endif %}{% if park.country and park.state or park.city %}, {% endif %}{% if park.country %}{{ park.country }}{% endif %}
</p>
{% endspaceless %}
{% endif %}
</div>
{% if user.is_authenticated %}
<div class="flex gap-2">
<a href="{% url 'parks:park_update' park.slug %}" class="btn-secondary">
<i class="mr-2 fas fa-pencil-alt"></i>Edit
</a>
{% if perms.media.add_photo %}
<button class="btn-secondary" @click="$dispatch('show-photo-upload')">
<i class="mr-2 fas fa-camera"></i>Upload Photo
</button>
{% endif %}
</div>
{% endif %}
</div>
<div class="flex flex-wrap gap-2 mt-3">
<span class="status-badge {% if park.status == 'OPERATING' %}status-operating
{% elif park.status == 'CLOSED_TEMP' or park.status == 'CLOSED_PERM' %}status-closed
{% elif park.status == 'UNDER_CONSTRUCTION' %}status-construction
{% elif park.status == 'DEMOLISHED' %}status-demolished
{% elif park.status == 'RELOCATED' %}status-relocated{% endif %}">
{{ park.get_status_display }}
</span>
{% if park.average_rating %}
<span class="flex items-center text-yellow-800 bg-yellow-100 status-badge dark:bg-yellow-600 dark:text-yellow-50">
<span class="mr-1 text-yellow-500 dark:text-yellow-200"></span>
{{ park.average_rating|floatformat:1 }}/10
</span>
{% endif %}
</div>
</div>
<!-- Quick Facts in Header -->
<div class="lg:w-1/3">
<dl class="grid grid-cols-2 gap-4">
{% if park.owner %}
<div>
<dt class="text-sm text-gray-500">Owner/Operator</dt>
<dd class="font-medium text-gray-900 dark:text-white">
<a href="{% url 'companies:company_detail' park.owner.slug %}"
class="text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300">
{{ park.owner.name }}
</a>
</dd>
</div>
{% endif %}
{% if park.opening_date %}
<div>
<dt class="text-sm text-gray-500">Opening Date</dt>
<dd class="font-medium text-gray-900 dark:text-white">{{ park.opening_date }}</dd>
</div>
{% endif %}
{% if park.operating_season %}
<div>
<dt class="text-sm text-gray-500">Operating Season</dt>
<dd class="font-medium text-gray-900 dark:text-white">{{ park.operating_season }}</dd>
</div>
{% endif %}
{% if park.size_acres %}
<div>
<dt class="text-sm text-gray-500">Size</dt>
<dd class="font-medium text-gray-900 dark:text-white">{{ park.size_acres }} acres</dd>
</div>
{% endif %}
{% if park.total_rides %}
<div>
<dt class="text-sm text-gray-500">Total Rides</dt>
<dd class="font-medium text-gray-900 dark:text-white">{{ park.total_rides }}</dd>
</div>
{% endif %}
{% if park.total_roller_coasters %}
<div>
<dt class="text-sm text-gray-500">Roller Coasters</dt>
<dd class="font-medium text-gray-900 dark:text-white">{{ park.total_roller_coasters }}</dd>
</div>
{% endif %}
{% if park.website %}
<div class="col-span-2">
<dt class="text-sm text-gray-500">Website</dt>
<dd class="font-medium text-gray-900 dark:text-white">
<a href="{{ park.website }}"
class="text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300"
target="_blank" rel="noopener noreferrer">
<i class="mr-2 fas fa-external-link-alt"></i>Official Website
</a>
</dd>
</div>
{% endif %}
</dl>
</div>
</div>
</div>
<!-- Photos -->
{% if park.photos.exists %}
<div class="p-6 mb-8 bg-white rounded-lg shadow dark:bg-gray-800">
<h2 class="mb-4 text-xl font-semibold text-gray-900 dark:text-white">Photos</h2>
{% include "media/partials/photo_display.html" with photos=park.photos.all content_type="parks.park" object_id=park.id %}
</div>
{% endif %}
<!-- Main Content Grid -->
<div class="grid grid-cols-1 gap-6 lg:grid-cols-3">
<!-- Left Column - Description and Rides -->
<div class="lg:col-span-2">
{% if park.description %}
<div class="p-6 mb-6 bg-white rounded-lg shadow dark:bg-gray-800">
<h2 class="mb-4 text-xl font-semibold text-gray-900 dark:text-white">About</h2>
<div class="prose dark:prose-invert max-w-none">
{{ park.description|linebreaks }}
</div>
</div>
{% endif %}
<!-- Rides and Attractions -->
<div class="p-6 mb-6 bg-white rounded-lg shadow dark:bg-gray-800">
<div class="flex items-center justify-between mb-4">
<h2 class="text-xl font-semibold text-gray-900 dark:text-white">Rides & Attractions</h2>
<a href="{% url 'parks:rides:ride_list' park.slug %}" class="text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300">
View All
</a>
</div>
{% if park.rides.exists %}
<div class="grid gap-4 md:grid-cols-2">
{% for ride in park.rides.all|slice:":6" %}
<div class="p-4 transition-colors rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700">
<a href="{% url 'parks:rides:ride_detail' park.slug ride.slug %}" class="block">
<h3 class="mb-1 font-semibold text-gray-900 dark:text-white">{{ ride.name }}</h3>
<span class="text-blue-800 bg-blue-100 status-badge dark:bg-blue-700 dark:text-blue-50">
{{ ride.get_category_display }}
</span>
{% if ride.average_rating %}
<span class="flex items-center text-yellow-800 bg-yellow-100 status-badge dark:bg-yellow-600 dark:text-yellow-50">
<span class="mr-1 text-yellow-500 dark:text-yellow-200"></span>
{{ ride.average_rating|floatformat:1 }}/10
</span>
{% endif %}
</a>
</div>
{% endfor %}
</div>
{% else %}
<p class="text-gray-500 dark:text-gray-400">No rides or attractions listed yet.</p>
{% endif %}
</div>
</div>
<!-- Right Column - Map and Additional Info -->
<div class="lg:col-span-1">
<!-- Location Map -->
{% if park.latitude and park.longitude %}
<div class="p-6 mb-6 bg-white rounded-lg shadow dark:bg-gray-800">
<h2 class="mb-4 text-xl font-semibold text-gray-900 dark:text-white">Location</h2>
<div id="map" class="relative rounded-lg" style="z-index: 0;"></div>
</div>
{% endif %}
<!-- History Panel -->
<div class="p-6 mb-6 bg-white rounded-lg shadow dark:bg-gray-800">
<h2 class="mb-4 text-xl font-semibold text-gray-900 dark:text-white">History</h2>
<div class="space-y-4">
{% for record in history %}
<div class="p-4 rounded-lg bg-gray-50 dark:bg-gray-700/50">
<div class="text-sm text-gray-500 dark:text-gray-400">
{{ record.history_date|date:"M d, Y H:i" }}
{% if record.history_user %}
by {{ record.history_user.username }}
{% endif %}
</div>
<div class="mt-2">
{% for field, changes in record.diff_against_previous.items %}
<div class="text-sm">
<span class="font-medium">{{ field }}:</span>
{{ changes.old }} → {{ changes.new }}
</div>
{% endfor %}
</div>
</div>
{% empty %}
<p class="text-gray-500">No history available.</p>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
<!-- Photo Upload Modal -->
{% if perms.media.add_photo %}
<div x-data="{ show: false }"
@show-photo-upload.window="show = true"
x-show="show"
class="fixed inset-0 z-[60] flex items-center justify-center bg-black bg-opacity-50"
@click.self="show = false">
<div class="w-full max-w-2xl p-6 mx-4 bg-white rounded-lg shadow-xl dark:bg-gray-800">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">Upload Photos</h3>
<button @click="show = false" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
<i class="text-xl fas fa-times"></i>
</button>
</div>
{% include "media/partials/photo_upload.html" with content_type="parks.park" object_id=park.id %}
</div>
</div>
{% endif %}
{% if park.latitude and park.longitude %}
{% block extra_js %}
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Make map container square based on its width
const mapContainer = document.getElementById('map');
const width = mapContainer.offsetWidth;
mapContainer.style.height = width + 'px';
const map = L.map('map').setView([{{ park.latitude }}, {{ park.longitude }}], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
L.marker([{{ park.latitude }}, {{ park.longitude }}])
.addTo(map)
.bindPopup("{{ park.name }}");
// Update map size when window is resized
window.addEventListener('resize', function() {
const width = mapContainer.offsetWidth;
mapContainer.style.height = width + 'px';
map.invalidateSize();
});
});
</script>
{% endblock %}
{% endif %}
{% block extra_head %}
{% if park.latitude and park.longitude %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
{% endif %}
{% endblock %}
{% endblock %}