111 lines
2.6 KiB
HTML
111 lines
2.6 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
|
<div class="container">
|
|
<div class="admin-header">
|
|
<h1>{% if current_user.is_admin %}Recipe Management{% else %}My Recipes{% endif %}</h1>
|
|
<div class="admin-actions">
|
|
{% if current_user.is_admin %}
|
|
<a href="{{ url_for('list_users') }}" class="btn">Manage Users</a>
|
|
{% endif %}
|
|
<a href="{{ url_for('add_recipe') }}" class="btn">Add New Recipe</a>
|
|
<a href="{{ url_for('logout') }}" class="btn btn-secondary">Logout</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="recipes-list">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Title</th>
|
|
<th>Created By</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for recipe in recipes %}
|
|
<tr>
|
|
<td>{{ recipe.title }}</td>
|
|
<td>{{ recipe.author.username if recipe.author else 'Unknown' }}</td>
|
|
<td class="actions">
|
|
{% if current_user.is_admin or recipe.user_id == current_user.id %}
|
|
<a href="{{ url_for('edit_recipe', recipe_id=recipe.id) }}" class="btn btn-small">Edit</a>
|
|
<a href="{{ url_for('delete_recipe', recipe_id=recipe.id) }}" class="btn btn-small btn-danger" onclick="return confirm('Are you sure you want to delete this recipe?')">Delete</a>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.admin-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.admin-actions {
|
|
display: flex;
|
|
gap: 1rem;
|
|
}
|
|
|
|
.recipes-list {
|
|
background: var(--background-color);
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
th, td {
|
|
padding: 1rem;
|
|
text-align: left;
|
|
}
|
|
|
|
th, tr {
|
|
border-bottom: 1px solid var(--border-color);
|
|
}
|
|
|
|
th {
|
|
background: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
.actions {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.btn-small {
|
|
padding: 0.25rem 0.5rem;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.btn-danger {
|
|
background: var(--error-color);
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background: var(--error-color-dark);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: var(--secondary-color);
|
|
color: white;
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: var(--secondary-color-dark);
|
|
}
|
|
</style>
|
|
{% endblock %}
|