61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
"""
|
|
init_db.py — Injection des widgets par défaut du tableau de bord au premier
|
|
démarrage (les tables elles-mêmes sont créées par init.sql, exécuté
|
|
automatiquement par le conteneur MariaDB).
|
|
|
|
Usage : python init_db.py
|
|
"""
|
|
|
|
from config import Config
|
|
from db import init_db
|
|
from models import block_model
|
|
|
|
INITIAL_BLOCKS = [
|
|
{
|
|
"type": "iframe",
|
|
"column": "left",
|
|
"data": {
|
|
"title": "Planning / Agenda",
|
|
"url": "https://chat.ninolbt.com/boards/team/example/planning",
|
|
"height": "100%",
|
|
"styleClass": "planning",
|
|
},
|
|
},
|
|
{
|
|
"type": "iframe",
|
|
"column": "center",
|
|
"data": {
|
|
"title": "",
|
|
"url": "https://chat.ninolbt.com/boards/team/example/kanban",
|
|
"height": "680",
|
|
"styleClass": "trello",
|
|
},
|
|
},
|
|
{
|
|
"type": "buttons",
|
|
"column": "right",
|
|
"data": {
|
|
"links": [
|
|
{"label": "Projet", "url": "#"},
|
|
{"label": "Documentation", "url": "#"},
|
|
{"label": "Règlement du HUB", "url": "#"},
|
|
]
|
|
},
|
|
},
|
|
]
|
|
|
|
|
|
def main():
|
|
db = init_db(Config)
|
|
if block_model.fetch_all(db):
|
|
print("La base de données contient déjà des blocs.")
|
|
return
|
|
print("Injection des widgets par défaut...")
|
|
for block in INITIAL_BLOCKS:
|
|
block_model.insert(db, block["type"], block["column"], block["data"])
|
|
print("Terminé.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|