Files
c0mrade 9a2aea038a chore: add uv package manager and ruff linter configuration
- Add pyproject.toml with uv and ruff configuration
- Pin Python version to 3.13 via .python-version
- Add Makefile commands: lint, format, fix
- Apply ruff formatting to entire codebase
- Remove unused imports (base64 in yookassa/simple_subscription)
- Update .gitignore for new config files
2026-01-24 17:45:27 +03:00

34 lines
977 B
Python

from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.database.models import SystemSetting
async def upsert_system_setting(
db: AsyncSession,
key: str,
value: str | None,
description: str | None = None,
) -> SystemSetting:
result = await db.execute(select(SystemSetting).where(SystemSetting.key == key))
setting = result.scalar_one_or_none()
if setting is None:
setting = SystemSetting(key=key, value=value, description=description)
db.add(setting)
else:
setting.value = value
if description is not None:
setting.description = description
await db.flush()
return setting
async def delete_system_setting(db: AsyncSession, key: str) -> None:
result = await db.execute(select(SystemSetting).where(SystemSetting.key == key))
setting = result.scalar_one_or_none()
if setting is not None:
await db.delete(setting)
await db.flush()