2022-08-31 13:54:13 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
"""
|
|
|
|
Admin Panel
|
|
|
|
"""
|
|
|
|
import os
|
2023-06-22 16:06:48 +02:00
|
|
|
from flask import Blueprint, abort, send_file, render_template, session
|
2022-08-31 13:54:13 +02:00
|
|
|
|
|
|
|
from .db import get_db
|
|
|
|
from .auth import admin_required
|
|
|
|
from .utils import User
|
|
|
|
|
|
|
|
|
|
|
|
bp = Blueprint("admin", __name__, url_prefix="/admin")
|
|
|
|
|
|
|
|
@bp.route("/")
|
|
|
|
@admin_required
|
|
|
|
def index():
|
2023-06-10 16:49:07 +02:00
|
|
|
current_user = User(user_id=session.get("user_id"))
|
2023-06-22 16:06:48 +02:00
|
|
|
current_user.get_albums() # We need to do that before we close the db
|
2022-08-31 13:54:13 +02:00
|
|
|
db = get_db()
|
|
|
|
users_id = db.execute(
|
|
|
|
"""
|
|
|
|
SELECT id FROM user
|
|
|
|
"""
|
|
|
|
)
|
2022-12-19 15:19:58 +01:00
|
|
|
users = [User(user_id=u["id"]) for u in users_id]
|
2022-08-31 13:54:13 +02:00
|
|
|
for u in users:
|
|
|
|
u.albums = u.get_albums()
|
2022-12-19 15:19:58 +01:00
|
|
|
u.partitions = u.get_partitions()
|
|
|
|
|
2022-08-31 13:54:13 +02:00
|
|
|
return render_template(
|
|
|
|
"admin/index.html",
|
2023-06-10 16:49:07 +02:00
|
|
|
users=users,
|
|
|
|
user=current_user
|
2022-08-31 13:54:13 +02:00
|
|
|
)
|