partitioncloud-server/partitioncloud/modules/admin.py

38 lines
800 B
Python
Raw Permalink Normal View History

2022-08-31 13:54:13 +02:00
#!/usr/bin/python3
"""
Admin Panel
"""
2023-12-15 11:36:34 +01:00
from flask import Blueprint, 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-12-15 11:36:34 +01:00
"""
Admin panel home page
"""
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
"""
)
2023-12-15 13:38:32 +01:00
users = [User(user_id=user["id"]) for user in users_id]
for user in users:
user.get_albums()
user.get_partitions()
2022-12-19 15:19:58 +01:00
2022-08-31 13:54:13 +02:00
return render_template(
"admin/index.html",
users=users,
user=current_user
2023-12-15 11:36:34 +01:00
)