transfer from private server/git server
This commit is contained in:
25
web/services/block_service.py
Normal file
25
web/services/block_service.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""block_service.py — Logique métier du tableau de bord (widgets)."""
|
||||
|
||||
from models import block_model
|
||||
|
||||
|
||||
def list_blocks(db):
|
||||
return block_model.fetch_all(db)
|
||||
|
||||
|
||||
def add_block(db, block_type, column, data):
|
||||
if block_type not in {"iframe", "buttons", "html"}:
|
||||
raise ValueError(f"Type de bloc inconnu : {block_type}")
|
||||
if column not in {"left", "center", "right"}:
|
||||
raise ValueError(f"Colonne inconnue : {column}")
|
||||
return block_model.insert(db, block_type, column, data)
|
||||
|
||||
|
||||
def save_layout(db, layout):
|
||||
"""layout : liste de {id, column, position} après un drag & drop."""
|
||||
for item in layout:
|
||||
block_model.update_position(db, item["id"], item["column"], item["position"])
|
||||
|
||||
|
||||
def delete_block(db, block_id):
|
||||
return block_model.delete(db, block_id)
|
||||
Reference in New Issue
Block a user