2022-08-16 15:21:12 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import os
|
2022-08-30 19:47:29 +02:00
|
|
|
|
2023-10-10 11:14:16 +02:00
|
|
|
from .db import get_db
|
2022-12-19 15:19:58 +01:00
|
|
|
|
2023-10-10 11:14:16 +02:00
|
|
|
from .classes.user import User
|
|
|
|
from .classes.album import Album
|
2023-10-11 17:15:49 +02:00
|
|
|
from .classes.groupe import Groupe
|
2023-10-10 11:14:16 +02:00
|
|
|
from .classes.partition import Partition
|
2022-12-19 15:19:58 +01:00
|
|
|
|
|
|
|
|
2022-08-16 18:13:00 +02:00
|
|
|
def get_all_partitions():
|
|
|
|
db = get_db()
|
|
|
|
partitions = db.execute(
|
|
|
|
"""
|
|
|
|
SELECT * FROM partition
|
|
|
|
"""
|
|
|
|
)
|
2022-12-19 15:19:58 +01:00
|
|
|
# Transform sql object to dictionary usable in any thread
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
"uuid": p["uuid"],
|
|
|
|
"name": p["name"],
|
|
|
|
"author": p["author"],
|
|
|
|
"body": p["body"],
|
|
|
|
"user_id": p["user_id"]
|
|
|
|
} for p in partitions
|
|
|
|
]
|
|
|
|
|
|
|
|
def get_all_albums():
|
|
|
|
db = get_db()
|
|
|
|
albums = db.execute(
|
|
|
|
"""
|
|
|
|
SELECT * FROM album
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
# Transform sql object to dictionary usable in any thread
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
"id": a["id"],
|
|
|
|
"name": a["name"],
|
|
|
|
"uuid": a["uuid"]
|
|
|
|
} for a in albums
|
|
|
|
]
|