Enable editing of competition details and images in the admin panel
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
This commit is contained in:
@@ -116,12 +116,35 @@
|
||||
.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 %}
|
||||
|
||||
@@ -179,17 +202,67 @@
|
||||
<h3 class="comp-title">{{ comp.event_name }}</h3>
|
||||
<p class="comp-meta">{{ comp.season }} · {{ comp.date }}</p>
|
||||
</div>
|
||||
<form method="POST" action="{{ url_for('delete_competition') }}">
|
||||
<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 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 %}
|
||||
|
||||
Reference in New Issue
Block a user