transfer from private server/git server
This commit is contained in:
@@ -1,65 +1,60 @@
|
||||
from app import app, db, Block
|
||||
import json
|
||||
"""
|
||||
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).
|
||||
|
||||
# Configuration des widgets actuels extraits de ton index.html
|
||||
initial_blocks = [
|
||||
# 1. Colonne GAUCHE : Le Planning
|
||||
Block(
|
||||
block_type='iframe',
|
||||
column_name='left',
|
||||
position=0,
|
||||
data=json.dumps({
|
||||
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://mattermost.ninolbt.com/boards/team/8xj6d4ukwigk7rznqi3w339x7e/b3kmbqfwd33dmdy9g9g3ezaoxza/vu4nuxhf73ircznrkrcgzonno8a",
|
||||
"url": "https://chat.ninolbt.com/boards/team/example/planning",
|
||||
"height": "100%",
|
||||
"styleClass": "planning"
|
||||
})
|
||||
),
|
||||
# 2. Colonne CENTRALE : Le Trello (Board)
|
||||
Block(
|
||||
block_type='iframe',
|
||||
column_name='center',
|
||||
position=0,
|
||||
data=json.dumps({
|
||||
"styleClass": "planning",
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "iframe",
|
||||
"column": "center",
|
||||
"data": {
|
||||
"title": "",
|
||||
"url": "https://mattermost.ninolbt.com/boards/team/8xj6d4ukwigk7rznqi3w339x7e/b3kmbqfwd33dmdy9g9g3ezaoxza/va5xp53m6spbi8qo6qnng7711me",
|
||||
"url": "https://chat.ninolbt.com/boards/team/example/kanban",
|
||||
"height": "680",
|
||||
"styleClass": "trello"
|
||||
})
|
||||
),
|
||||
# 3. Colonne DROITE : Les boutons
|
||||
Block(
|
||||
block_type='buttons',
|
||||
column_name='right',
|
||||
position=0,
|
||||
data=json.dumps({
|
||||
"styleClass": "trello",
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "buttons",
|
||||
"column": "right",
|
||||
"data": {
|
||||
"links": [
|
||||
{"label": "Projet", "url": "#"},
|
||||
{"label": "GDD Global", "url": "#"},
|
||||
{"label": "Bible 3D Art", "url": "#"},
|
||||
{"label": "Bible GameDev", "url": "#"},
|
||||
{"label": "Réglement du HUB", "url": "#"}
|
||||
{"label": "Documentation", "url": "#"},
|
||||
{"label": "Règlement du HUB", "url": "#"},
|
||||
]
|
||||
})
|
||||
)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
def init_data():
|
||||
with app.app_context():
|
||||
# Crée les tables si elles n'existent pas encore
|
||||
db.create_all()
|
||||
|
||||
# Vérifie si la DB est déjà remplie pour éviter les doublons
|
||||
if Block.query.first():
|
||||
print("La base de données contient déjà des blocs.")
|
||||
return
|
||||
|
||||
print("Injection des widgets par défaut...")
|
||||
for block in initial_blocks:
|
||||
db.session.add(block)
|
||||
|
||||
db.session.commit()
|
||||
print("Terminé ! Tes widgets sont en base de données.")
|
||||
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__":
|
||||
init_data()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user