Add a custom Jinja filter `image_url` to `app.py` to correctly resolve image paths from object storage or local static files, and update all relevant templates (members, sponsors, competitions, contributors) to use this new filter instead of the `url_for('static', filename=...)` function, ensuring images are displayed correctly regardless of their storage location.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: cd9a7d26-a4e5-4215-975c-c59f4ed1f06d
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: a02b1418-2e19-496d-9921-3a4afe97ac0d
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/d0a1d46d-d203-4308-bc6a-312ac7c0243b/cd9a7d26-a4e5-4215-975c-c59f4ed1f06d/05bPjFc
260 lines
8.3 KiB
HTML
260 lines
8.3 KiB
HTML
{% extends "admin/base.html" %}
|
|
|
|
{% block title %}Members & Mentors 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 {
|
|
width: 100%;
|
|
padding: 10px 12px;
|
|
background: #0d0d0d;
|
|
border: 1px solid #333;
|
|
border-radius: 8px;
|
|
color: #fff;
|
|
font-size: 14px;
|
|
}
|
|
.form-input:focus, .form-select:focus {
|
|
outline: none;
|
|
border-color: #3b82f6;
|
|
}
|
|
.members-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
gap: 24px;
|
|
}
|
|
.member-card-admin {
|
|
background: #1a1a1a;
|
|
border: 1px solid #333;
|
|
border-radius: 16px;
|
|
padding: 20px;
|
|
}
|
|
.member-image-admin {
|
|
width: 100%;
|
|
height: 200px;
|
|
object-fit: cover;
|
|
border-radius: 12px;
|
|
margin-bottom: 16px;
|
|
}
|
|
.member-name-admin {
|
|
font-family: var(--font-display);
|
|
font-size: 20px;
|
|
color: var(--white);
|
|
margin-bottom: 8px;
|
|
}
|
|
.member-role-admin {
|
|
color: var(--gray-400);
|
|
font-family: var(--font-body);
|
|
font-size: 14px;
|
|
margin-bottom: 16px;
|
|
}
|
|
.btn {
|
|
padding: 10px 20px;
|
|
border-radius: 8px;
|
|
border: none;
|
|
font-family: var(--font-body);
|
|
font-size: 14px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
margin-right: 8px;
|
|
}
|
|
.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-edit {
|
|
background: rgba(59, 130, 246, 0.2);
|
|
color: var(--blue);
|
|
}
|
|
.btn-edit:hover {
|
|
background: rgba(59, 130, 246, 0.3);
|
|
}
|
|
.modal {
|
|
display: none;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: rgba(0, 0, 0, 0.8);
|
|
z-index: 1000;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.modal.active {
|
|
display: flex;
|
|
}
|
|
.modal-content {
|
|
background: #1a1a1a;
|
|
border: 1px solid #333;
|
|
border-radius: 16px;
|
|
padding: 32px;
|
|
max-width: 500px;
|
|
width: 90%;
|
|
}
|
|
.modal-close {
|
|
float: right;
|
|
font-size: 28px;
|
|
cursor: pointer;
|
|
color: var(--gray-400);
|
|
}
|
|
.modal-close:hover {
|
|
color: var(--white);
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<h1 class="admin-header">Members & Mentors Management</h1>
|
|
|
|
<div class="section">
|
|
<h2 class="section-title">Add New Member/Mentor</h2>
|
|
<div class="add-form">
|
|
<form method="POST" action="{{ url_for('add_member') }}" enctype="multipart/form-data">
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label class="form-label">Name</label>
|
|
<input type="text" name="name" class="form-input" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Role</label>
|
|
<input type="text" name="role" class="form-input" placeholder="e.g., SOFTWARE, HARDWARE" required>
|
|
</div>
|
|
</div>
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label class="form-label">Type</label>
|
|
<select name="type" class="form-select" required>
|
|
<option value="member">Team Member</option>
|
|
<option value="mentor">Mentor</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Profile Image</label>
|
|
<input type="file" name="image" class="form-input" accept="image/*">
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Add</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h2 class="section-title">Mentors</h2>
|
|
<div class="members-grid">
|
|
{% for mentor in mentors %}
|
|
<div class="member-card-admin">
|
|
<img src="{{ mentor.image_path|image_url }}" class="member-image-admin" alt="{{ mentor.name }}">
|
|
<h3 class="member-name-admin">{{ mentor.name }}</h3>
|
|
<p class="member-role-admin">{{ mentor.role }}</p>
|
|
<button onclick="openEditModal('mentor', {{ mentor.id }}, '{{ mentor.name }}', '{{ mentor.role }}')" class="btn btn-edit">Edit</button>
|
|
<form method="POST" action="{{ url_for('delete_member') }}" style="display: inline;">
|
|
<input type="hidden" name="id" value="{{ mentor.id }}">
|
|
<input type="hidden" name="type" value="mentor">
|
|
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure?')">Delete</button>
|
|
</form>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h2 class="section-title">Team Members</h2>
|
|
<div class="members-grid">
|
|
{% for member in members %}
|
|
<div class="member-card-admin">
|
|
<img src="{{ member.image_path|image_url }}" class="member-image-admin" alt="{{ member.name }}">
|
|
<h3 class="member-name-admin">{{ member.name }}</h3>
|
|
<p class="member-role-admin">{{ member.role }}</p>
|
|
<button onclick="openEditModal('member', {{ member.id }}, '{{ member.name }}', '{{ member.role }}')" class="btn btn-edit">Edit</button>
|
|
<form method="POST" action="{{ url_for('delete_member') }}" style="display: inline;">
|
|
<input type="hidden" name="id" value="{{ member.id }}">
|
|
<input type="hidden" name="type" value="member">
|
|
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure?')">Delete</button>
|
|
</form>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<div id="editModal" class="modal">
|
|
<div class="modal-content">
|
|
<span class="modal-close" onclick="closeEditModal()">×</span>
|
|
<h2 class="section-title">Edit Member</h2>
|
|
<form method="POST" action="{{ url_for('update_member') }}" enctype="multipart/form-data">
|
|
<input type="hidden" name="id" id="edit-id">
|
|
<input type="hidden" name="type" id="edit-type">
|
|
<div class="form-group">
|
|
<label class="form-label">Name</label>
|
|
<input type="text" name="name" id="edit-name" class="form-input" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Role</label>
|
|
<input type="text" name="role" id="edit-role" class="form-input" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="form-label">Profile Image (optional)</label>
|
|
<input type="file" name="image" class="form-input" accept="image/*">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Update</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function openEditModal(type, id, name, role) {
|
|
document.getElementById('edit-id').value = id;
|
|
document.getElementById('edit-type').value = type;
|
|
document.getElementById('edit-name').value = name;
|
|
document.getElementById('edit-role').value = role;
|
|
document.getElementById('editModal').classList.add('active');
|
|
}
|
|
|
|
function closeEditModal() {
|
|
document.getElementById('editModal').classList.remove('active');
|
|
}
|
|
</script>
|
|
{% endblock %}
|