country_mode in database/ payment options
This commit is contained in:
@@ -11,6 +11,22 @@ from ..defaults import DEFAULT_MONEY_CONFIG
|
||||
MONEY_CONFIG: dict[str, Any] = DEFAULT_MONEY_CONFIG.copy()
|
||||
|
||||
|
||||
def get_currency_mode() -> tuple[str, bool]:
|
||||
mode_cfg = MONEY_CONFIG.get("CURRENCY_MODE", "RUB")
|
||||
raw = str(mode_cfg or "RUB").upper()
|
||||
|
||||
if raw not in ("RUB", "USD", "RUB+USD", "RUB+USD_ONE_SCREEN"):
|
||||
raw = "RUB"
|
||||
|
||||
one_screen = raw == "RUB+USD_ONE_SCREEN"
|
||||
if raw in ("RUB+USD", "RUB+USD_ONE_SCREEN"):
|
||||
base_mode = "RUB+USD"
|
||||
else:
|
||||
base_mode = raw
|
||||
|
||||
return base_mode, one_screen
|
||||
|
||||
|
||||
async def load_money_config(session: AsyncSession) -> None:
|
||||
stmt = select(Setting).where(Setting.key == "MONEY_CONFIG")
|
||||
result = await session.execute(stmt)
|
||||
|
||||
Reference in New Issue
Block a user