Add Exchange model, API endpoint, and form validation for creating new gift exchanges. - Create ExchangeForm with timezone validation - Add admin routes for creating and viewing exchanges - Generate unique 12-char slug for each exchange - Validate registration/exchange dates - Display exchanges in dashboard - All tests passing with 92% coverage Story: 2.1
68 lines
2.0 KiB
HTML
68 lines
2.0 KiB
HTML
{% extends "layouts/base.html" %}
|
|
|
|
{% block title %}Admin Dashboard - Sneaky Klaus{% endblock %}
|
|
|
|
{% block content %}
|
|
<article>
|
|
<header>
|
|
<h1>Admin Dashboard</h1>
|
|
<form method="POST" action="{{ url_for('admin.logout') }}" style="display: inline;">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<button type="submit" class="secondary">Logout</button>
|
|
</form>
|
|
</header>
|
|
|
|
<div class="dashboard-summary">
|
|
<div class="grid">
|
|
<div>
|
|
<h3>Draft</h3>
|
|
<p><strong>{{ draft_count }}</strong></p>
|
|
</div>
|
|
<div>
|
|
<h3>Active</h3>
|
|
<p><strong>{{ active_count }}</strong></p>
|
|
</div>
|
|
<div>
|
|
<h3>Completed</h3>
|
|
<p><strong>{{ completed_count }}</strong></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="margin: 2rem 0;">
|
|
<a href="{{ url_for('admin.create_exchange') }}" role="button">Create New Exchange</a>
|
|
</div>
|
|
|
|
<h2>All Exchanges</h2>
|
|
|
|
{% if exchanges %}
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>State</th>
|
|
<th>Participants</th>
|
|
<th>Exchange Date</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for exchange in exchanges %}
|
|
<tr>
|
|
<td>{{ exchange.name }}</td>
|
|
<td><mark>{{ exchange.state }}</mark></td>
|
|
<td>0 / {{ exchange.max_participants }}</td>
|
|
<td>{{ exchange.exchange_date.strftime('%Y-%m-%d') }}</td>
|
|
<td>
|
|
<a href="{{ url_for('admin.view_exchange', exchange_id=exchange.id) }}">View</a>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% else %}
|
|
<p>No exchanges yet. <a href="{{ url_for('admin.create_exchange') }}">Create your first exchange</a>!</p>
|
|
{% endif %}
|
|
</article>
|
|
{% endblock %}
|