mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 11:11:10 -05:00
feat: Implement ride management views and utility functions
- Added functions for checking user privileges, handling photo uploads, preparing form data, and managing form errors. - Created views for listing, creating, updating, and displaying rides, including category-specific views. - Integrated submission handling for ride changes and improved user feedback through messages. - Enhanced data handling with appropriate context and queryset management for better performance and usability.
This commit is contained in:
@@ -22,12 +22,12 @@
|
||||
{% endif %}
|
||||
|
||||
<!-- Header Grid -->
|
||||
<div class="grid grid-cols-1 gap-2 mb-8 sm:grid-cols-12">
|
||||
<div class="grid grid-cols-1 gap-4 mb-8 sm:grid-cols-12">
|
||||
<!-- Ride Info Card -->
|
||||
<div class="flex flex-col items-center justify-center h-full col-span-1 p-2 text-center bg-white rounded-lg shadow-lg sm:col-span-3 dark:bg-gray-800">
|
||||
<div class="flex flex-col items-center justify-center h-full col-span-1 p-4 text-center bg-white rounded-lg shadow-lg sm:col-span-3 dark:bg-gray-800">
|
||||
<h1 class="text-2xl font-bold leading-tight text-gray-900 sm:text-3xl dark:text-white">{{ ride.name }}</h1>
|
||||
|
||||
<div class="flex items-center justify-center mt-0.5 text-sm text-gray-600 dark:text-gray-400">
|
||||
<div class="flex items-center justify-center mt-2 text-sm text-gray-600 dark:text-gray-400">
|
||||
at <a href="{% url 'parks:park_detail' ride.park.slug %}" class="ml-1 text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300">
|
||||
{{ ride.park.name }}
|
||||
</a>
|
||||
@@ -36,20 +36,20 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-center gap-1 mt-1">
|
||||
<span class="status-badge text-xs sm:text-sm font-medium py-0.5 {% if ride.status == 'OPERATING' %}status-operating
|
||||
<div class="flex flex-wrap items-center justify-center gap-2 mt-3">
|
||||
<span class="px-3 py-1 text-xs font-medium status-badge sm:text-sm {% if ride.status == 'OPERATING' %}status-operating
|
||||
{% elif ride.status == 'CLOSED_TEMP' or ride.status == 'CLOSED_PERM' %}status-closed
|
||||
{% elif ride.status == 'UNDER_CONSTRUCTION' %}status-construction
|
||||
{% elif ride.status == 'DEMOLISHED' %}status-demolished
|
||||
{% elif ride.status == 'RELOCATED' %}status-relocated{% endif %}">
|
||||
{{ ride.get_status_display }}
|
||||
</span>
|
||||
<span class="text-blue-800 bg-blue-100 status-badge text-xs sm:text-sm font-medium py-0.5 dark:bg-blue-700 dark:text-blue-50">
|
||||
<span class="px-3 py-1 text-xs font-medium text-blue-800 bg-blue-100 status-badge sm:text-sm dark:bg-blue-700 dark:text-blue-50">
|
||||
{{ ride.get_category_display }}
|
||||
</span>
|
||||
{% if ride.average_rating %}
|
||||
<span class="flex items-center text-xs font-medium text-yellow-800 bg-yellow-100 sm:text-sm status-badge py-0.5 dark:bg-yellow-600 dark:text-yellow-50">
|
||||
<span class="mr-0.5 text-yellow-500 dark:text-yellow-200">★</span>
|
||||
<span class="flex items-center px-3 py-1 text-xs font-medium text-yellow-800 bg-yellow-100 status-badge sm:text-sm 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 %}
|
||||
@@ -57,46 +57,46 @@
|
||||
</div>
|
||||
|
||||
<!-- Stats and Quick Facts -->
|
||||
<div class="grid h-full grid-cols-12 col-span-1 gap-2 sm:col-span-9">
|
||||
<div class="grid h-full grid-cols-12 col-span-1 gap-4 sm:col-span-9">
|
||||
<!-- Stats Column -->
|
||||
<div class="grid grid-cols-2 col-span-12 gap-2 sm:col-span-4">
|
||||
<div class="grid grid-cols-2 col-span-12 gap-4 sm:col-span-4">
|
||||
{% if coaster_stats %}
|
||||
{% if coaster_stats.height_ft %}
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center bg-white rounded-lg shadow-lg dark:bg-gray-800">
|
||||
<div class="flex flex-col items-center justify-center p-4 text-center bg-white rounded-lg shadow-lg dark:bg-gray-800">
|
||||
<dt class="text-sm font-semibold text-gray-900 sm:text-base dark:text-white">Height</dt>
|
||||
<dd class="mt-0.5 text-xl font-bold text-sky-900 sm:text-2xl dark:text-sky-400">{{ coaster_stats.height_ft }} ft</dd>
|
||||
<dd class="mt-2 text-xl font-bold text-sky-900 sm:text-2xl dark:text-sky-400">{{ coaster_stats.height_ft }} ft</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if coaster_stats.speed_mph %}
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center bg-white rounded-lg shadow-lg dark:bg-gray-800">
|
||||
<div class="flex flex-col items-center justify-center p-4 text-center bg-white rounded-lg shadow-lg dark:bg-gray-800">
|
||||
<dt class="text-sm font-semibold text-gray-900 sm:text-base dark:text-white">Speed</dt>
|
||||
<dd class="mt-0.5 text-xl font-bold text-sky-900 sm:text-2xl dark:text-sky-400">{{ coaster_stats.speed_mph }} mph</dd>
|
||||
<dd class="mt-2 text-xl font-bold text-sky-900 sm:text-2xl dark:text-sky-400">{{ coaster_stats.speed_mph }} mph</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if coaster_stats.inversions %}
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center bg-white rounded-lg shadow-lg dark:bg-gray-800">
|
||||
<div class="flex flex-col items-center justify-center p-4 text-center bg-white rounded-lg shadow-lg dark:bg-gray-800">
|
||||
<dt class="text-sm font-semibold text-gray-900 sm:text-base dark:text-white">Inversions</dt>
|
||||
<dd class="mt-0.5 text-xl font-bold text-sky-900 sm:text-2xl dark:text-sky-400">{{ coaster_stats.inversions }}</dd>
|
||||
<dd class="mt-2 text-xl font-bold text-sky-900 sm:text-2xl dark:text-sky-400">{{ coaster_stats.inversions }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if coaster_stats.length_ft %}
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center bg-white rounded-lg shadow-lg dark:bg-gray-800">
|
||||
<div class="flex flex-col items-center justify-center p-4 text-center bg-white rounded-lg shadow-lg dark:bg-gray-800">
|
||||
<dt class="text-sm font-semibold text-gray-900 sm:text-base dark:text-white">Length</dt>
|
||||
<dd class="mt-0.5 text-xl font-bold text-sky-900 sm:text-2xl dark:text-sky-400">{{ coaster_stats.length_ft }} ft</dd>
|
||||
<dd class="mt-2 text-xl font-bold text-sky-900 sm:text-2xl dark:text-sky-400">{{ coaster_stats.length_ft }} ft</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Quick Facts Grid -->
|
||||
<div class="grid h-full grid-cols-3 col-span-12 gap-1 p-1.5 bg-white rounded-lg shadow-lg sm:col-span-8 dark:bg-gray-800">
|
||||
<div class="grid h-full grid-cols-3 col-span-12 gap-2 p-4 bg-white rounded-lg shadow-lg sm:col-span-8 dark:bg-gray-800">
|
||||
{% if ride.manufacturer %}
|
||||
<div class="flex flex-col items-center justify-center text-center p-0.5">
|
||||
<i class="text-sm text-blue-600 sm:text-base fas fa-industry dark:text-blue-400"></i>
|
||||
<dt class="font-medium text-gray-500 text-2xs dark:text-gray-400">Manufacturer</dt>
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center">
|
||||
<i class="text-lg text-blue-600 sm:text-xl fas fa-industry dark:text-blue-400"></i>
|
||||
<dt class="mt-1 text-xs font-medium text-gray-500 dark:text-gray-400">Manufacturer</dt>
|
||||
<dd>
|
||||
<a href="{% url 'companies:manufacturer_detail' ride.manufacturer.slug %}"
|
||||
class="text-blue-600 text-2xs sm:text-xs hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300">
|
||||
class="text-xs text-blue-600 sm:text-sm hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300">
|
||||
{{ ride.manufacturer.name }}
|
||||
</a>
|
||||
</dd>
|
||||
@@ -104,12 +104,12 @@
|
||||
{% endif %}
|
||||
|
||||
{% if ride.designer %}
|
||||
<div class="flex flex-col items-center justify-center text-center p-0.5">
|
||||
<i class="text-sm text-blue-600 sm:text-base fas fa-drafting-compass dark:text-blue-400"></i>
|
||||
<dt class="font-medium text-gray-500 text-2xs dark:text-gray-400">Designer</dt>
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center">
|
||||
<i class="text-lg text-blue-600 sm:text-xl fas fa-drafting-compass dark:text-blue-400"></i>
|
||||
<dt class="mt-1 text-xs font-medium text-gray-500 dark:text-gray-400">Designer</dt>
|
||||
<dd>
|
||||
<a href="{% url 'designers:designer_detail' ride.designer.slug %}"
|
||||
class="text-blue-600 text-2xs sm:text-xs hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300">
|
||||
class="text-xs text-blue-600 sm:text-sm hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300">
|
||||
{{ ride.designer.name }}
|
||||
</a>
|
||||
</dd>
|
||||
@@ -117,49 +117,49 @@
|
||||
{% endif %}
|
||||
|
||||
{% if coaster_stats.roller_coaster_type %}
|
||||
<div class="flex flex-col items-center justify-center text-center p-0.5">
|
||||
<i class="text-sm text-blue-600 sm:text-base fas fa-train dark:text-blue-400"></i>
|
||||
<dt class="font-medium text-gray-500 text-2xs dark:text-gray-400">Coaster Type</dt>
|
||||
<dd class="text-gray-900 text-2xs sm:text-xs dark:text-white">{{ coaster_stats.get_roller_coaster_type_display }}</dd>
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center">
|
||||
<i class="text-lg text-blue-600 sm:text-xl fas fa-train dark:text-blue-400"></i>
|
||||
<dt class="mt-1 text-xs font-medium text-gray-500 dark:text-gray-400">Coaster Type</dt>
|
||||
<dd class="text-xs text-gray-900 sm:text-sm dark:text-white">{{ coaster_stats.get_roller_coaster_type_display }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if coaster_stats.track_material %}
|
||||
<div class="flex flex-col items-center justify-center text-center p-0.5">
|
||||
<i class="text-sm text-blue-600 sm:text-base fas fa-layer-group dark:text-blue-400"></i>
|
||||
<dt class="font-medium text-gray-500 text-2xs dark:text-gray-400">Track Material</dt>
|
||||
<dd class="text-gray-900 text-2xs sm:text-xs dark:text-white">{{ coaster_stats.get_track_material_display }}</dd>
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center">
|
||||
<i class="text-lg text-blue-600 sm:text-xl fas fa-layer-group dark:text-blue-400"></i>
|
||||
<dt class="mt-1 text-xs font-medium text-gray-500 dark:text-gray-400">Track Material</dt>
|
||||
<dd class="text-xs text-gray-900 sm:text-sm dark:text-white">{{ coaster_stats.get_track_material_display }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if ride.opening_date %}
|
||||
<div class="flex flex-col items-center justify-center text-center p-0.5">
|
||||
<i class="text-sm text-blue-600 sm:text-base fas fa-calendar-alt dark:text-blue-400"></i>
|
||||
<dt class="font-medium text-gray-500 text-2xs dark:text-gray-400">Opened</dt>
|
||||
<dd class="text-gray-900 text-2xs sm:text-xs dark:text-white">{{ ride.opening_date }}</dd>
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center">
|
||||
<i class="text-lg text-blue-600 sm:text-xl fas fa-calendar-alt dark:text-blue-400"></i>
|
||||
<dt class="mt-1 text-xs font-medium text-gray-500 dark:text-gray-400">Opened</dt>
|
||||
<dd class="text-xs text-gray-900 sm:text-sm dark:text-white">{{ ride.opening_date }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if ride.capacity_per_hour %}
|
||||
<div class="flex flex-col items-center justify-center text-center p-0.5">
|
||||
<i class="text-sm text-blue-600 sm:text-base fas fa-users dark:text-blue-400"></i>
|
||||
<dt class="font-medium text-gray-500 text-2xs dark:text-gray-400">Capacity</dt>
|
||||
<dd class="text-gray-900 text-2xs sm:text-xs dark:text-white">{{ ride.capacity_per_hour }}/hr</dd>
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center">
|
||||
<i class="text-lg text-blue-600 sm:text-xl fas fa-users dark:text-blue-400"></i>
|
||||
<dt class="mt-1 text-xs font-medium text-gray-500 dark:text-gray-400">Capacity</dt>
|
||||
<dd class="text-xs text-gray-900 sm:text-sm dark:text-white">{{ ride.capacity_per_hour }}/hr</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if coaster_stats.launch_type %}
|
||||
<div class="flex flex-col items-center justify-center text-center p-0.5">
|
||||
<i class="text-sm text-blue-600 sm:text-base fas fa-rocket dark:text-blue-400"></i>
|
||||
<dt class="font-medium text-gray-500 text-2xs dark:text-gray-400">Launch Type</dt>
|
||||
<dd class="text-gray-900 text-2xs sm:text-xs dark:text-white">{{ coaster_stats.get_launch_type_display }}</dd>
|
||||
<div class="flex flex-col items-center justify-center p-2 text-center">
|
||||
<i class="text-lg text-blue-600 sm:text-xl fas fa-rocket dark:text-blue-400"></i>
|
||||
<dt class="mt-1 text-xs font-medium text-gray-500 dark:text-gray-400">Launch Type</dt>
|
||||
<dd class="text-xs text-gray-900 sm:text-sm dark:text-white">{{ coaster_stats.get_launch_type_display }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Photos Section -->
|
||||
<!-- Rest of the content remains unchanged -->
|
||||
{% if ride.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>
|
||||
@@ -486,3 +486,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script src="{% static 'js/photo-gallery.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user