feat: implement Story 3.1 Open Registration

Add complete implementation with tests:
- New route POST /admin/exchange/<id>/state/open-registration
- State validation (only from draft state)
- Success/error messages
- Authentication required
- Update exchange detail template with "Open Registration" button
- 8 comprehensive integration tests

All acceptance criteria met:
- "Open Registration" action available from Draft state
- Exchange state changes to "Registration Open"
- Registration link becomes active
- Participants can now access registration form
- Success message displayed
- Only admin can perform action
- Redirects to exchange detail after completion

Story: 3.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-22 13:06:00 -07:00
parent 3b0257c377
commit cc865a85dc
4 changed files with 653 additions and 0 deletions

View File

@@ -180,3 +180,34 @@ def view_exchange(exchange_id):
"""
exchange = db.session.query(Exchange).get_or_404(exchange_id)
return render_template("admin/exchange_detail.html", exchange=exchange)
@admin_bp.route("/exchange/<int:exchange_id>/state/open-registration", methods=["POST"])
@admin_required
def open_registration(exchange_id):
"""Open registration for an exchange.
Changes exchange state from draft to registration_open.
Args:
exchange_id: ID of the exchange.
Returns:
Redirect to exchange detail page.
"""
exchange = db.session.query(Exchange).get_or_404(exchange_id)
# Validate current state
if exchange.state != Exchange.STATE_DRAFT:
flash(
"Registration can only be opened from Draft state.",
"error",
)
return redirect(url_for("admin.view_exchange", exchange_id=exchange.id))
# Update state
exchange.state = Exchange.STATE_REGISTRATION_OPEN
db.session.commit()
flash("Registration is now open!", "success")
return redirect(url_for("admin.view_exchange", exchange_id=exchange.id))

View File

@@ -42,6 +42,12 @@
</div>
<div class="actions">
{% if exchange.state == 'draft' %}
<form method="POST" action="{{ url_for('admin.open_registration', exchange_id=exchange.id) }}" style="display: inline;">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button type="submit" class="btn btn-primary">Open Registration</button>
</form>
{% endif %}
<a href="{{ url_for('admin.dashboard') }}" class="btn btn-secondary">Back to Dashboard</a>
</div>
</div>