diff --git "a/app.py" "b/app.py" --- "a/app.py" +++ "b/app.py" @@ -101,8 +101,6 @@ translations = { 'online_order': 'Онлайн', 'address_1_title': 'Адрес:', 'address_1_detail': 'Город Алматы, Рынок Олжа, ряд VIP, Бутик 7', - 'currency_usd': 'USD', - 'currency_kzt': 'KZT', }, 'kk': { 'site_title': "ManolisA - Каталог", @@ -171,8 +169,6 @@ translations = { 'online_order': 'Онлайн', 'address_1_title': 'Мекенжай:', 'address_1_detail': 'Алматы қаласы, Олжа базары, VIP қатары, 7 бутик', - 'currency_usd': 'USD', - 'currency_kzt': 'KZT', } } @@ -232,7 +228,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_to_kzt_rate': 450.0}}, f) + json.dump({'products': [], 'categories': [], 'seasons': [], 'orders': {}, 'employees': [], 'settings': {'usd_kzt_rate': 450}}, 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}") @@ -296,7 +292,7 @@ def periodic_backup(): def load_data(): - default_data = {'products': [], 'categories': [], 'seasons': [], 'orders': {}, 'employees': [], 'settings': {'usd_to_kzt_rate': 450.0}} + default_data = {'products': [], 'categories': [], 'seasons': [], 'orders': {}, 'employees': [], 'settings': {'usd_kzt_rate': 450}} try: with open(DATA_FILE, 'r', encoding='utf-8') as file: data = json.load(file) @@ -309,7 +305,7 @@ def load_data(): 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_to_kzt_rate': 450.0} + if 'settings' not in data: data['settings'] = {'usd_kzt_rate': 450} return data except FileNotFoundError: logging.warning(f"Local file {DATA_FILE} not found. Attempting download from HF.") @@ -327,7 +323,7 @@ def load_data(): 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_to_kzt_rate': 450.0} + if 'settings' not in data: data['settings'] = {'usd_kzt_rate': 450} return data except FileNotFoundError: logging.error(f"File {DATA_FILE} still not found even after download reported success. Using default.") @@ -359,7 +355,8 @@ def save_data(data): 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_to_kzt_rate': 450.0} + if 'settings' not in data: data['settings'] = {'usd_kzt_rate': 450} + with open(DATA_FILE, 'w', encoding='utf-8') as file: json.dump(data, file, ensure_ascii=False, indent=4) @@ -377,136 +374,151 @@ CATALOG_TEMPLATE = '''
+ {% if first_photo %}
+
+ {% endif %}
{{ _('total_to_pay') }}: {{ "%.2f"|format(order.total_price) }} {{ order.currency }}
+ {% set total_price_display = (order.total_price * order.exchange_rate) if order.currency == 'KZT' else order.total_price %} +{{ _('total_to_pay') }}: {{ "%.0f"|format(total_price_display) if currency_symbol == '₸' else "%.2f"|format(total_price_display) }} {{ currency_symbol }}
{{ _('order_not_found') }}
{{ _('back_to_catalog') }} {% endif %} @@ -1318,66 +1297,74 @@ ADMIN_TEMPLATE = '''Резервное копирование происходит автоматически каждые 30 минут, а также после каждого сохранения данных. Используйте эти кнопки для немедленной синхронизации.
-Категорий пока нет.
{% endfor %}Сезонов пока нет.
{% endfor %}Сотрудников пока нет.
{% endfor %}
-
+ {% endif %}
+ Категория: {{ product.get('category', 'Без категории') }} | Сезон: {{ product.get('season', 'Без сезона') }}
-Цена: {{ "%.2f"|format(product['price']) }} USD | В линейке: {{ product.get('items_per_line', 'N/A') }} шт.
- {% if product.variants %} -Варианты: {{ product.variants|map(attribute='color')|join(', ') }}
- {% endif %} +Категория: {{ product.get('category', 'Без категории') }}
+Сезон: {{ product.get('season', 'Без сезона') }}
+Цена: {{ "%.2f"|format(product.price) }} USD
+Шт. в линейке: {{ product.get('items_per_line', 'N/A') }}
+Цвета/Вар-ты: {{ (product.get('variants', [])|map(attribute='color')|list)|join(', ') }}
Товаров пока нет.
- {% endif %} + {% else %}Товаров пока нет.
{% endif %} -