feat: implement pivot-currency model, rbac smart tokens & fix circular imports
This commit is contained in:
43
backend/app/scripts/seed_system_params.py
Normal file
43
backend/app/scripts/seed_system_params.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import asyncio
|
||||
import json
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from app.models.system_config import SystemParameter
|
||||
from app.core.config import settings
|
||||
|
||||
async def seed_system():
|
||||
engine = create_async_engine(settings.DATABASE_URL)
|
||||
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
||||
|
||||
async with async_session() as session:
|
||||
params = [
|
||||
{
|
||||
"key": "fuel_types",
|
||||
"value": ["Benzin (95)", "Benzin (100)", "Dízel", "Prémium Dízel", "LPG", "Elektromos", "Hibrid"],
|
||||
"description": "Rendszerben használható üzemanyag típusok"
|
||||
},
|
||||
{
|
||||
"key": "currencies",
|
||||
"value": ["HUF", "EUR", "USD", "GBP"],
|
||||
"description": "Támogatott pénznemek"
|
||||
},
|
||||
{
|
||||
"key": "expense_categories",
|
||||
"value": ["Üzemanyag", "Szerviz", "Biztosítás", "Autópálya matrica", "Parkolás", "Adó", "Egyéb"],
|
||||
"description": "Költség kategóriák"
|
||||
}
|
||||
]
|
||||
|
||||
for p in params:
|
||||
# Megnézzük, létezik-e már
|
||||
from sqlalchemy import select
|
||||
result = await session.execute(select(SystemParameter).where(SystemParameter.key == p["key"]))
|
||||
if not result.scalar_one_or_none():
|
||||
new_param = SystemParameter(**p)
|
||||
session.add(new_param)
|
||||
|
||||
await session.commit()
|
||||
print("✅ Rendszer paraméterek sikeresen feltöltve!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(seed_system())
|
||||
Reference in New Issue
Block a user