Adds a new POST route `/admin/competition/edit` to update competition data in the database, including handling image uploads and preserving existing images. Updates `replit.md` and `templates/admin/competitions.html` to include UI elements and logic for editing competitions. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cd9a7d26-a4e5-4215-975c-c59f4ed1f06d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 5f81296b-a857-4536-9a1e-2ccf05671a10 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/d0a1d46d-d203-4308-bc6a-312ac7c0243b/cd9a7d26-a4e5-4215-975c-c59f4ed1f06d/EU15Bjz
269 lines
9.3 KiB
HTML
269 lines
9.3 KiB
HTML
{% extends "admin/base.html" %}
|
|
|
|
{% block title %}Competitions Management{% endblock %}
|
|
|
|
{% block extra_styles %}
|
|
<style>
|
|
.section {
|
|
margin-bottom: 48px;
|
|
}
|
|
.section-title {
|
|
font-family: var(--font-display);
|
|
font-size: 28px;
|
|
color: var(--white);
|
|
margin-bottom: 24px;
|
|
}
|
|
.add-form {
|
|
background: #1a1a1a;
|
|
border: 1px solid #333;
|
|
border-radius: 16px;
|
|
padding: 24px;
|
|
margin-bottom: 32px;
|
|
}
|
|
.form-row {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 16px;
|
|
}
|
|
.form-label {
|
|
display: block;
|
|
color: var(--gray-300);
|
|
margin-bottom: 6px;
|
|
font-family: var(--font-body);
|
|
font-size: 14px;
|
|
}
|
|
.form-input, .form-select, .form-textarea {
|
|
width: 100%;
|
|
padding: 10px 12px;
|
|
background: #0d0d0d;
|
|
border: 1px solid #333;
|
|
border-radius: 8px;
|
|
color: #fff;
|
|
font-size: 14px;
|
|
}
|
|
.form-textarea {
|
|
min-height: 100px;
|
|
resize: vertical;
|
|
}
|
|
.form-input:focus, .form-select:focus, .form-textarea:focus {
|
|
outline: none;
|
|
border-color: var(--blue);
|
|
}
|
|
.competitions-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20px;
|
|
}
|
|
.comp-card {
|
|
background: #1a1a1a;
|
|
border: 1px solid #333;
|
|
border-radius: 16px;
|
|
padding: 24px;
|
|
}
|
|
.comp-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: start;
|
|
margin-bottom: 16px;
|
|
}
|
|
.comp-title {
|
|
font-family: var(--font-display);
|
|
font-size: 22px;
|
|
color: var(--white);
|
|
margin-bottom: 4px;
|
|
}
|
|
.comp-meta {
|
|
color: var(--gray-400);
|
|
font-family: var(--font-body);
|
|
font-size: 14px;
|
|
}
|
|
.comp-description {
|
|
color: var(--gray-300);
|
|
font-family: var(--font-body);
|
|
margin-bottom: 12px;
|
|
line-height: 1.6;
|
|
}
|
|
.comp-awards {
|
|
color: var(--gray-400);
|
|
font-family: var(--font-body);
|
|
font-size: 14px;
|
|
}
|
|
.btn {
|
|
padding: 10px 20px;
|
|
border-radius: 8px;
|
|
border: none;
|
|
font-family: var(--font-body);
|
|
font-size: 14px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
}
|
|
.btn-primary {
|
|
background: var(--blue);
|
|
color: var(--white);
|
|
}
|
|
.btn-primary:hover {
|
|
background: var(--blue-light);
|
|
transform: translateY(-2px);
|
|
}
|
|
.btn-danger {
|
|
background: rgba(239, 68, 68, 0.2);
|
|
color: #ef4444;
|
|
}
|
|
.btn-danger:hover {
|
|
background: rgba(239, 68, 68, 0.3);
|
|
}
|
|
.btn-warning {
|
|
background: rgba(251, 191, 36, 0.2);
|
|
color: #fbbf24;
|
|
margin-right: 8px;
|
|
}
|
|
.btn-warning:hover {
|
|
background: rgba(251, 191, 36, 0.3);
|
|
}
|
|
.info-text {
|
|
color: var(--gray-400);
|
|
font-family: var(--font-body);
|
|
font-size: 13px;
|
|
margin-top: 4px;
|
|
}
|
|
.edit-form {
|
|
display: none;
|
|
background: #0d0d0d;
|
|
border: 1px solid #444;
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
margin-top: 16px;
|
|
}
|
|
.edit-form.active {
|
|
display: block;
|
|
}
|
|
.action-buttons {
|
|
display: flex;
|
|
gap: 8px;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<h1 class="admin-header">Competitions Management</h1>
|
|
|
|
<div class="section">
|
|
<h2 class="section-title">Add New Competition</h2>
|
|
<div class="add-form">
|
|
<form method="POST" action="{{ url_for('add_competition') }}" enctype="multipart/form-data">
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label class="form-label">Season</label>
|
|
<input type="text" name="season" class="form-input" placeholder="e.g., Into The Deep" list="seasons" required>
|
|
<datalist id="seasons">
|
|
{% for season in seasons %}
|
|
<option value="{{ season }}">
|
|
{% endfor %}
|
|
</datalist>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Event Name</label>
|
|
<input type="text" name="event_name" class="form-input" required>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Date</label>
|
|
<input type="text" name="date" class="form-input" placeholder="e.g., 06/19/2025 or 11/11/23 - 01/06/24" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Description</label>
|
|
<textarea name="description" class="form-textarea" required></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Awards (optional)</label>
|
|
<textarea name="awards" class="form-textarea" placeholder="One award per line"></textarea>
|
|
<p class="info-text">Enter each award on a new line</p>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Competition Image (optional)</label>
|
|
<input type="file" name="image" class="form-input" accept="image/*">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Add Competition</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h2 class="section-title">Existing Competitions</h2>
|
|
<div class="competitions-list">
|
|
{% for comp in competitions %}
|
|
<div class="comp-card">
|
|
<div class="comp-header">
|
|
<div>
|
|
<h3 class="comp-title">{{ comp.event_name }}</h3>
|
|
<p class="comp-meta">{{ comp.season }} · {{ comp.date }}</p>
|
|
</div>
|
|
<div class="action-buttons">
|
|
<button type="button" class="btn btn-warning" onclick="toggleEdit({{ comp.id }})">Edit</button>
|
|
<form method="POST" action="{{ url_for('delete_competition') }}" style="display: inline;">
|
|
<input type="hidden" name="id" value="{{ comp.id }}">
|
|
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure?')">Delete</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<p class="comp-description">{{ comp.description }}</p>
|
|
{% if comp.awards %}
|
|
<p class="comp-awards">🏆 {{ comp.awards|replace('|', ' · ') }}</p>
|
|
{% endif %}
|
|
|
|
<div id="edit-form-{{ comp.id }}" class="edit-form">
|
|
<form method="POST" action="{{ url_for('edit_competition') }}" enctype="multipart/form-data">
|
|
<input type="hidden" name="id" value="{{ comp.id }}">
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label class="form-label">Season</label>
|
|
<input type="text" name="season" class="form-input" value="{{ comp.season }}" list="seasons" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Event Name</label>
|
|
<input type="text" name="event_name" class="form-input" value="{{ comp.event_name }}" required>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Date</label>
|
|
<input type="text" name="date" class="form-input" value="{{ comp.date }}" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Description</label>
|
|
<textarea name="description" class="form-textarea" required>{{ comp.description }}</textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Awards (optional)</label>
|
|
<textarea name="awards" class="form-textarea" placeholder="One award per line">{{ comp.awards|replace('|', '\n') if comp.awards else '' }}</textarea>
|
|
<p class="info-text">Enter each award on a new line</p>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Competition Image (optional)</label>
|
|
<input type="file" name="image" class="form-input" accept="image/*">
|
|
{% if comp.image_path %}
|
|
<p class="info-text">Current image: {{ comp.image_path }}</p>
|
|
{% endif %}
|
|
</div>
|
|
<div class="action-buttons">
|
|
<button type="submit" class="btn btn-primary">Save Changes</button>
|
|
<button type="button" class="btn btn-danger" onclick="toggleEdit({{ comp.id }})">Cancel</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function toggleEdit(competitionId) {
|
|
const editForm = document.getElementById('edit-form-' + competitionId);
|
|
editForm.classList.toggle('active');
|
|
}
|
|
</script>
|
|
{% endblock %}
|