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:
104
src/templates/admin/exchange_form.html
Normal file
104
src/templates/admin/exchange_form.html
Normal file
@@ -0,0 +1,104 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block title %}{% if is_edit %}Edit Exchange{% else %}Create Exchange{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>{% if is_edit %}Edit Exchange{% else %}Create New Exchange{% endif %}</h1>
|
||||
|
||||
<form method="POST" novalidate>
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<div class="form-group">
|
||||
{{ form.name.label }}
|
||||
{{ form.name(class="form-control") }}
|
||||
{% if form.name.errors %}
|
||||
<div class="error">
|
||||
{% for error in form.name.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ form.description.label }}
|
||||
{{ form.description(class="form-control", rows=4) }}
|
||||
{% if form.description.errors %}
|
||||
<div class="error">
|
||||
{% for error in form.description.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ form.budget.label }}
|
||||
{{ form.budget(class="form-control", placeholder="e.g., $20-30") }}
|
||||
{% if form.budget.errors %}
|
||||
<div class="error">
|
||||
{% for error in form.budget.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ form.max_participants.label }}
|
||||
{{ form.max_participants(class="form-control", min=3) }}
|
||||
{% if form.max_participants.errors %}
|
||||
<div class="error">
|
||||
{% for error in form.max_participants.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ form.registration_close_date.label }}
|
||||
{{ form.registration_close_date(class="form-control") }}
|
||||
{% if form.registration_close_date.errors %}
|
||||
<div class="error">
|
||||
{% for error in form.registration_close_date.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ form.exchange_date.label }}
|
||||
{{ form.exchange_date(class="form-control") }}
|
||||
{% if form.exchange_date.errors %}
|
||||
<div class="error">
|
||||
{% for error in form.exchange_date.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ form.timezone.label }}
|
||||
{{ form.timezone(class="form-control") }}
|
||||
{% if form.timezone.errors %}
|
||||
<div class="error">
|
||||
{% for error in form.timezone.errors %}
|
||||
<span>{{ error }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{% if is_edit %}Update Exchange{% else %}Create Exchange{% endif %}
|
||||
</button>
|
||||
<a href="{{ url_for('admin.dashboard') }}" class="btn btn-secondary">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user