mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-23 09:31:07 -05:00
Add test utilities and state machine diagrams for FSM models
- Introduced reusable test utilities in `backend/tests/utils` for FSM transitions, HTMX interactions, and common scenarios. - Added factory functions for creating test submissions, parks, rides, and photo submissions. - Implemented assertion helpers for verifying state changes, toast notifications, and transition logs. - Created comprehensive state machine diagrams for all FSM-enabled models in `docs/STATE_DIAGRAMS.md`, detailing states, transitions, and guard conditions.
This commit is contained in:
30
backend/templates/parks/partials/park_header_badge.html
Normal file
30
backend/templates/parks/partials/park_header_badge.html
Normal file
@@ -0,0 +1,30 @@
|
||||
{# Park header status badge partial - refreshes via HTMX on park-status-changed #}
|
||||
<span id="park-header-badge"
|
||||
hx-get="{% url 'parks:park_header_badge' park.slug %}"
|
||||
hx-trigger="park-status-changed from:body"
|
||||
hx-swap="outerHTML">
|
||||
{% if perms.parks.change_park %}
|
||||
<!-- Clickable status badge for moderators -->
|
||||
<button type="button"
|
||||
onclick="document.getElementById('park-status-section').scrollIntoView({behavior: 'smooth'})"
|
||||
class="status-badge text-sm font-medium py-1 px-3 transition-all hover:ring-2 hover:ring-blue-500 cursor-pointer
|
||||
{% 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 }}
|
||||
<i class="fas fa-chevron-down ml-1 text-xs"></i>
|
||||
</button>
|
||||
{% else %}
|
||||
<!-- Static status badge for non-moderators -->
|
||||
<span class="status-badge text-sm font-medium py-1 px-3
|
||||
{% 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>
|
||||
{% endif %}
|
||||
</span>
|
||||
23
backend/templates/parks/partials/park_history.html
Normal file
23
backend/templates/parks/partials/park_history.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{% comment %}
|
||||
Park FSM History Partial Template
|
||||
|
||||
Displays FSM transition history for a specific park.
|
||||
Loaded via HTMX when the history section is expanded.
|
||||
|
||||
Required context:
|
||||
- park: The Park model instance
|
||||
{% endcomment %}
|
||||
|
||||
<div class="mt-4">
|
||||
<div id="park-history-container"
|
||||
hx-get="{% url 'moderation:moderation-reports-all-history' %}?model_type=park&object_id={{ park.id }}"
|
||||
hx-trigger="load"
|
||||
hx-swap="innerHTML"
|
||||
hx-indicator="#park-history-loading">
|
||||
<!-- Loading State -->
|
||||
<div id="park-history-loading" class="flex items-center justify-center py-8">
|
||||
<i class="mr-2 text-blue-500 fas fa-spinner fa-spin"></i>
|
||||
<span class="text-gray-600 dark:text-gray-400">Loading history...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
19
backend/templates/parks/partials/park_status_actions.html
Normal file
19
backend/templates/parks/partials/park_status_actions.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{% load fsm_tags %}
|
||||
|
||||
{# This partial is loaded via HTMX into #park-status-section. It must include the container #}
|
||||
{# element with the same id and hx-* attributes to preserve targeting for subsequent transitions. #}
|
||||
<div id="park-status-section"
|
||||
data-park-status-actions
|
||||
hx-get="{% url 'parks:park_status_actions' park.slug %}"
|
||||
hx-trigger="park-status-changed from:body"
|
||||
hx-swap="outerHTML">
|
||||
{% if user.is_authenticated and perms.parks.change_park %}
|
||||
<div class="mb-6 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg">
|
||||
<h3 class="text-sm font-semibold text-blue-900 dark:text-blue-100 mb-3">
|
||||
<i class="fas fa-cog mr-2"></i>Status Management
|
||||
</h3>
|
||||
|
||||
{% include "htmx/status_with_actions.html" with object=park user=user target_id="park-status-section" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
Reference in New Issue
Block a user