Integrate parks app with site-wide search system; add filter configuration, error handling, and search interfaces

This commit is contained in:
pacnpal
2025-02-12 16:59:20 -05:00
parent af57592496
commit 1fe299fb4b
13 changed files with 1267 additions and 72 deletions

View File

@@ -0,0 +1,55 @@
{% extends "search/layouts/filtered_list.html" %}
{% load filter_utils %}
{% block page_title %}Parks{% endblock %}
{% block filter_errors %}
{% if filter.errors %}
<div class="bg-red-50 border-l-4 border-red-400 p-4 mb-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">Please correct the following errors:</h3>
<div class="mt-2 text-sm text-red-700">
<ul class="list-disc pl-5 space-y-1">
{% for field, errors in filter.errors.items %}
{% for error in errors %}
<li>{{ field }}: {{ error }}</li>
{% endfor %}
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}
{% block list_header %}
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-bold text-gray-900">Parks</h1>
{% if user.is_authenticated %}
<a href="{% url 'parks:park_create' %}" class="btn btn-primary">
Add Park
</a>
{% endif %}
</div>
{% endblock %}
{% block list_description %}
Browse and filter amusement parks, theme parks, and water parks from around the world.
{% endblock %}
{% block filter_section_title %}Find Parks{% endblock %}
{% block results_section_title %}Parks{% endblock %}
{% block no_results_message %}
<div class="text-center p-8 text-gray-500">
No parks found matching your criteria. Try adjusting your filters or <a href="{% url 'parks:park_create' %}" class="text-blue-600 hover:underline">add a new park</a>.
</div>
{% endblock %}

View File

@@ -0,0 +1,35 @@
{% if error %}
<div class="p-2 text-red-600">
{{ error }}
</div>
{% else %}
{% for park in parks %}
<div class="p-2 hover:bg-gray-100 cursor-pointer">
<div class="flex items-center space-x-3">
{% if park.photos.exists %}
<img src="{{ park.photos.first.image.url }}"
alt="{{ park.name }}"
class="w-8 h-8 object-cover rounded">
{% else %}
<div class="w-8 h-8 bg-gray-200 rounded flex items-center justify-center">
<span class="text-xs text-gray-500">{{ park.name|first|upper }}</span>
</div>
{% endif %}
<div>
<div class="font-medium">{{ park.name }}</div>
{% with location=park.location.first %}
{% if location %}
<div class="text-sm text-gray-500">
{{ location.city }}{% if location.state %}, {{ location.state }}{% endif %}
</div>
{% endif %}
{% endwith %}
</div>
</div>
</div>
{% empty %}
<div class="p-2 text-gray-500 text-center">
No parks found
</div>
{% endfor %}
{% endif %}