{% comment %} Ride Card Component - Django Cotton Version A comprehensive ride card component with image handling, status badges, feature displays, and robust URL generation that supports both global and park-specific URL patterns. Includes graceful handling of missing slugs to prevent 500 errors. Usage Examples: Basic usage (default global URL pattern): Park-specific URL pattern: With custom CSS classes: With custom image fallback: Parameters: - ride: Ride object (required) - url_variant: URL pattern type - 'global' (default) or 'park' (optional) - class: Additional CSS classes (optional) - fallback_gradient: Custom gradient for image fallback (default: "from-blue-500 to-purple-600") URL Pattern Logic: - If url_variant='global' and ride.slug exists: uses rides:ride_detail with ride.slug - If url_variant='park' and both ride.park.slug and ride.slug exist: uses parks:rides:ride_detail with ride.park.slug, ride.slug - If no valid URL can be generated: renders ride name as plain text (no link) Features: - Graceful handling of missing slugs (prevents NoReverseMatch errors) - Support for both global and park-specific URL patterns - Image handling with gradient fallback backgrounds - Status badges with proper color coding (operating, closed_temporarily, closed_permanently, under_construction) - Ride name with conditional linking based on slug availability - Category and park information display - Statistics grid for height, speed, capacity, duration - Special features badges (inversions, launches, track_type) - Opening date and manufacturer/designer information - Responsive design with hover effects - Modern Tailwind styling and animations - Backwards compatibility with existing usage {% endcomment %} {% if ride %}
{% if ride.card_image %} {{ ride.name }} {% elif ride.photos.first %} {{ ride.name }} {% else %}
{% endif %}
{% if ride.operating_status == 'operating' or ride.operating_status == 'OPERATING' %} Operating {% elif ride.operating_status == 'closed_temporarily' or ride.operating_status == 'CLOSED_TEMP' %} Temporarily Closed {% elif ride.operating_status == 'closed_permanently' or ride.operating_status == 'CLOSED_PERM' %} Permanently Closed {% elif ride.operating_status == 'under_construction' or ride.operating_status == 'UNDER_CONSTRUCTION' %} Under Construction {% elif ride.operating_status == 'sbno' or ride.operating_status == 'SBNO' %} SBNO {% endif %}

{% comment %}Robust URL generation with missing slug handling{% endcomment %} {% if url_variant == 'park' and ride.park and ride.park.slug and ride.slug %} {{ ride.name }} {% elif url_variant == 'global' and ride.slug %} {{ ride.name }} {% else %} {% comment %}No valid URL can be generated - render as plain text{% endcomment %} {{ ride.name }} {% endif %}

{{ ride.category|default:"Ride" }} {% if ride.park %} {{ ride.park.name }} {% endif %}
{% if ride.height %}
{{ ride.height }}ft
Height
{% endif %} {% if ride.rollercoaster_stats.max_speed %}
{{ ride.rollercoaster_stats.max_speed }}mph
Top Speed
{% elif ride.max_speed %}
{{ ride.max_speed }}mph
Max Speed
{% endif %} {% if ride.capacity_per_hour %}
{{ ride.capacity_per_hour }}
Capacity/Hr
{% endif %} {% if ride.duration %}
{{ ride.duration }}s
Duration
{% endif %}
{% if ride.has_inversions or ride.has_launches or ride.rollercoaster_stats.track_type or ride.track_type %}
{% if ride.has_inversions %} {% if ride.rollercoaster_stats.number_of_inversions %} {{ ride.rollercoaster_stats.number_of_inversions }} Inversion{{ ride.rollercoaster_stats.number_of_inversions|pluralize }} {% else %} Inversions {% endif %} {% endif %} {% if ride.has_launches %} {% if ride.rollercoaster_stats.number_of_launches %} {{ ride.rollercoaster_stats.number_of_launches }} Launch{{ ride.rollercoaster_stats.number_of_launches|pluralize }} {% else %} Launched {% endif %} {% endif %} {% if ride.rollercoaster_stats.track_type %} {{ ride.rollercoaster_stats.track_type|title }} {% elif ride.track_type %} {{ ride.track_type|title }} {% endif %}
{% endif %} {% if ride.opened_date %}
Opened {{ ride.opened_date|date:"F j, Y" }}
{% endif %} {% if ride.manufacturer or ride.designer %}
{% if ride.manufacturer %}
{{ ride.manufacturer.name }}
{% endif %} {% if ride.designer and ride.designer != ride.manufacturer %}
Designed by {{ ride.designer.name }}
{% endif %}
{% endif %}
{% endif %}