feat: implement exchange creation

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
This commit is contained in:
2025-12-22 12:41:28 -07:00
parent 7580c39a84
commit 8554f27d86
12 changed files with 837 additions and 7 deletions

View File

@@ -0,0 +1,58 @@
{% extends "layouts/base.html" %}
{% block title %}{{ exchange.name }}{% endblock %}
{% block content %}
<div class="container">
<h1>{{ exchange.name }}</h1>
<div class="exchange-details">
<div class="detail-section">
<h2>Details</h2>
<dl>
<dt>State</dt>
<dd><span class="badge badge-{{ exchange.state }}">{{ exchange.state }}</span></dd>
<dt>Description</dt>
<dd>{{ exchange.description or "No description" }}</dd>
<dt>Budget</dt>
<dd>{{ exchange.budget }}</dd>
<dt>Max Participants</dt>
<dd>{{ exchange.max_participants }}</dd>
<dt>Registration Close Date</dt>
<dd>{{ exchange.registration_close_date.strftime('%Y-%m-%d %H:%M') }} {{ exchange.timezone }}</dd>
<dt>Exchange Date</dt>
<dd>{{ exchange.exchange_date.strftime('%Y-%m-%d %H:%M') }} {{ exchange.timezone }}</dd>
<dt>Registration Link</dt>
<dd>
<code id="registration-link">{{ url_for('participant.register', slug=exchange.slug, _external=True) }}</code>
<button type="button" onclick="copyToClipboard()">Copy</button>
</dd>
</dl>
</div>
<div class="detail-section">
<h2>Participants</h2>
<p>No participants yet.</p>
</div>
<div class="actions">
<a href="{{ url_for('admin.dashboard') }}" class="btn btn-secondary">Back to Dashboard</a>
</div>
</div>
</div>
<script>
function copyToClipboard() {
const link = document.getElementById('registration-link').textContent;
navigator.clipboard.writeText(link).then(() => {
alert('Link copied to clipboard!');
});
}
</script>
{% endblock %}