[V0.2] WORKING Working calendar and AI with full frontend.

This commit is contained in:
c-d-p
2025-04-20 12:12:35 +02:00
parent ee86374da6
commit 6cee996fb3
27 changed files with 996 additions and 488 deletions

View File

@@ -14,18 +14,24 @@ def read_admin():
return {"message": "Admin route"}
@router.get("/cleardb")
def clear_db(db: Annotated[Session, Depends(get_db)]):
def clear_db(db: Annotated[Session, Depends(get_db)], hard: bool):
"""
Clear the database.
'hard' parameter determines if the database should be completely reset.
"""
tables = Base.metadata.tables.keys()
for table in tables:
# delete all tables that isn't the users table
if table != "users":
table = Base.metadata.tables[table]
db.execute(table.delete())
if hard:
Base.metadata.drop_all(bind=db.get_bind())
Base.metadata.create_all(bind=db.get_bind())
return {"message": "Database reset (HARD)"}
else:
tables = Base.metadata.tables.keys()
for table_name in tables:
# delete all tables that isn't the users table
if table_name != "users":
table = Base.metadata.tables[table_name]
db.execute(table.delete())
# delete all non-admin accounts
db.query(User).filter(User.role != UserRole.ADMIN).delete()
db.commit()
return {"message": "Database cleared"}
db.query(User).filter(User.role != UserRole.ADMIN).delete()
db.commit()
return {"message": "Database cleared"}