diff --git "a/app.py" "b/app.py" --- "a/app.py" +++ "b/app.py" @@ -101,6 +101,8 @@ translations = { 'online_order': 'Онлайн', 'address_1_title': 'Адрес:', 'address_1_detail': 'Город Алматы, Рынок Олжа, ряд VIP, Бутик 7', + 'currency_usd': 'USD', + 'currency_kzt': 'KZT' }, 'kk': { 'site_title': "ManolisA - Каталог", @@ -169,6 +171,8 @@ translations = { 'online_order': 'Онлайн', 'address_1_title': 'Мекенжай:', 'address_1_detail': 'Алматы қаласы, Олжа базары, VIP қатары, 7 бутик', + 'currency_usd': 'USD', + 'currency_kzt': 'KZT' } } @@ -228,7 +232,7 @@ def download_db_from_hf(specific_file=None, retries=DOWNLOAD_RETRIES, delay=DOWN try: if file_name == DATA_FILE: with open(file_name, 'w', encoding='utf-8') as f: - json.dump({'products': [], 'categories': [], 'seasons': [], 'orders': {}, 'employees': [], 'settings': {'usd_kzt_rate': 450}}, f) + json.dump({'products': [], 'categories': [], 'orders': {}, 'employees': [], 'seasons': [], 'exchange_rate_kzt': 450.0}, f) logging.info(f"Created empty local file {file_name} because it was not found on HF.") except Exception as create_e: logging.error(f"Failed to create empty local file {file_name}: {create_e}") @@ -292,7 +296,7 @@ def periodic_backup(): def load_data(): - default_data = {'products': [], 'categories': [], 'seasons': [], 'orders': {}, 'employees': [], 'settings': {'usd_kzt_rate': 450}} + default_data = {'products': [], 'categories': [], 'orders': {}, 'employees': [], 'seasons': [], 'exchange_rate_kzt': 450.0} try: with open(DATA_FILE, 'r', encoding='utf-8') as file: data = json.load(file) @@ -302,10 +306,10 @@ def load_data(): raise FileNotFoundError if 'products' not in data: data['products'] = [] if 'categories' not in data: data['categories'] = [] - if 'seasons' not in data: data['seasons'] = [] if 'orders' not in data: data['orders'] = {} if 'employees' not in data: data['employees'] = [] - if 'settings' not in data: data['settings'] = {'usd_kzt_rate': 450} + if 'seasons' not in data: data['seasons'] = [] + if 'exchange_rate_kzt' not in data: data['exchange_rate_kzt'] = 450.0 return data except FileNotFoundError: logging.warning(f"Local file {DATA_FILE} not found. Attempting download from HF.") @@ -320,10 +324,10 @@ def load_data(): return default_data if 'products' not in data: data['products'] = [] if 'categories' not in data: data['categories'] = [] - if 'seasons' not in data: data['seasons'] = [] if 'orders' not in data: data['orders'] = {} if 'employees' not in data: data['employees'] = [] - if 'settings' not in data: data['settings'] = {'usd_kzt_rate': 450} + if 'seasons' not in data: data['seasons'] = [] + if 'exchange_rate_kzt' not in data: data['exchange_rate_kzt'] = 450.0 return data except FileNotFoundError: logging.error(f"File {DATA_FILE} still not found even after download reported success. Using default.") @@ -352,11 +356,10 @@ def save_data(data): return if 'products' not in data: data['products'] = [] if 'categories' not in data: data['categories'] = [] - if 'seasons' not in data: data['seasons'] = [] if 'orders' not in data: data['orders'] = {} if 'employees' not in data: data['employees'] = [] - if 'settings' not in data: data['settings'] = {'usd_kzt_rate': 450} - + if 'seasons' not in data: data['seasons'] = [] + if 'exchange_rate_kzt' not in data: data['exchange_rate_kzt'] = 450.0 with open(DATA_FILE, 'w', encoding='utf-8') as file: json.dump(data, file, ensure_ascii=False, indent=4) @@ -380,145 +383,135 @@ CATALOG_TEMPLATE = '''