Kgshop commited on
Commit
b345ec2
·
verified ·
1 Parent(s): 1ff6346

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +91 -147
app.py CHANGED
@@ -18,28 +18,25 @@ import uuid
18
  load_dotenv()
19
 
20
  app = Flask(__name__)
21
- app.secret_key = 'your_unique_secret_key_soola_cosmetics_67890_no_login' # Secret key still needed for flash messages
22
  DATA_FILE = 'data.json'
23
 
24
-
25
  SYNC_FILES = [DATA_FILE]
26
 
27
- REPO_ID = "Kgshop/medinaturkey"
28
  HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
29
  HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
30
 
31
- STORE_ADDRESS = "Рынок Байсат цокольный этаж ,оранжевый сектор, 142 бутик"
32
 
33
  CURRENCY_CODE = 'KZT'
34
  CURRENCY_NAME = 'Казахский тенге'
35
 
36
  DOWNLOAD_RETRIES = 3
37
- DOWNLOAD_DELAY = 5 # seconds
38
 
39
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
40
 
41
- # --- Hugging Face Sync Functions ---
42
-
43
  def download_db_from_hf(specific_file=None, retries=DOWNLOAD_RETRIES, delay=DOWNLOAD_DELAY):
44
  if not HF_TOKEN_READ and not HF_TOKEN_WRITE:
45
  logging.warning("HF_TOKEN_READ/HF_TOKEN_WRITE not set. Download might fail for private repos.")
@@ -139,8 +136,6 @@ def periodic_backup():
139
  upload_db_to_hf()
140
  logging.info("Periodic backup finished.")
141
 
142
- # --- Data Loading and Saving Functions ---
143
-
144
  def load_data():
145
  default_data = {'products': [], 'categories': [], 'orders': {}}
146
  try:
@@ -207,104 +202,77 @@ def save_data(data):
207
  except Exception as e:
208
  logging.error(f"Error saving data to {DATA_FILE}: {e}", exc_info=True)
209
 
210
- # --- Templates ---
211
-
212
  CATALOG_TEMPLATE = '''
213
  <!DOCTYPE html>
214
  <html lang="ru">
215
  <head>
216
  <meta charset="UTF-8">
217
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
218
- <title>MedinaTurkey.kz - Каталог</title>
219
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
220
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
221
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/10.2.0/swiper-bundle.min.css">
222
  <style>
223
  * { margin: 0; padding: 0; box-sizing: border-box; }
224
- body { font-family: 'Poppins', sans-serif; background: #f0f9f4; color: #2d332f; line-height: 1.6; transition: background 0.3s, color 0.3s; }
225
- body.dark-mode { background: #1a2b26; color: #c8d8d3; }
226
  .container { max-width: 1300px; margin: 0 auto; padding: 20px; }
227
- .header { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid #d1e7dd; }
228
- body.dark-mode .header { border-bottom-color: #2c4a41; }
229
- .header h1 { font-size: 1.8rem; font-weight: 600; color: #1C6758; }
230
- .theme-toggle { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #7a8d85; transition: color 0.3s ease; }
231
- .theme-toggle:hover { color: #3D8361; }
232
- body.dark-mode .theme-toggle { color: #8aa39a; }
233
- body.dark-mode .theme-toggle:hover { color: #55a683; }
234
- .store-address { padding: 15px; text-align: center; background-color: #ffffff; margin: 20px 0; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); font-size: 1rem; color: #44524c; }
235
- body.dark-mode .store-address { background-color: #253f37; color: #b0c8c1; }
236
  .filters-container { margin: 20px 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
237
  .search-container { margin: 20px 0; text-align: center; }
238
- #search-input { width: 90%; max-width: 600px; padding: 12px 18px; font-size: 1rem; border: 1px solid #d1e7dd; border-radius: 25px; outline: none; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: all 0.3s ease; }
239
- body.dark-mode #search-input { background-color: #253f37; border-color: #2c4a41; color: #c8d8d3; }
240
- #search-input:focus { border-color: #1C6758; box-shadow: 0 0 0 3px rgba(28, 103, 88, 0.2); }
241
- body.dark-mode #search-input:focus { border-color: #3D8361; box-shadow: 0 0 0 3px rgba(61, 131, 97, 0.3); }
242
- .category-filter { padding: 8px 16px; border: 1px solid #d1e7dd; border-radius: 20px; background-color: #fff; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); font-size: 0.9rem; font-weight: 400; color: #1C6758; }
243
- body.dark-mode .category-filter { background-color: #253f37; border-color: #2c4a41; color: #97b7ae; }
244
- .category-filter.active, .category-filter:hover { background-color: #1C6758; color: white; border-color: #1C6758; box-shadow: 0 2px 10px rgba(28, 103, 88, 0.3); }
245
- body.dark-mode .category-filter.active, body.dark-mode .category-filter:hover { background-color: #3D8361; border-color: #3D8361; color: #1a2b26; box-shadow: 0 2px 10px rgba(61, 131, 97, 0.4); }
246
  .products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px; padding: 10px; }
247
  @media (min-width: 600px) { .products-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
248
  @media (min-width: 900px) { .products-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); } }
249
 
250
- .product { background: #fff; border-radius: 15px; padding: 0; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; height: 100%; border: 1px solid #e1f0e9;}
251
- body.dark-mode .product { background: #253f37; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); border-color: #2c4a41; }
252
  .product:hover { transform: translateY(-5px) scale(1.02); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); }
253
- body.dark-mode .product:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
254
  .product-image { width: 100%; aspect-ratio: 1 / 1; background-color: #fff; border-radius: 10px 10px 0 0; overflow: hidden; display: flex; justify-content: center; align-items: center; margin-bottom: 0; }
255
  .product-image img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.3s ease; }
256
  .product-info { padding: 15px; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
257
- .product h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 8px 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #2d332f; }
258
- body.dark-mode .product h2 { color: #c8d8d3; }
259
- .product-price { font-size: 1.2rem; color: #1C6758; font-weight: 700; text-align: center; margin: 5px 0; }
260
- body.dark-mode .product-price { color: #55a683; }
261
- .product-description { font-size: 0.85rem; color: #7a8d85; text-align: center; margin-bottom: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
262
- body.dark-mode .product-description { color: #8aa39a; }
263
  .product-actions { padding: 0 15px 15px 15px; display: flex; flex-direction: column; gap: 8px; }
264
- .product-button { display: block; width: 100%; padding: 10px; border: none; border-radius: 8px; background-color: #1C6758; color: white; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); text-align: center; text-decoration: none; }
265
- .product-button:hover { background-color: #164B41; box-shadow: 0 4px 15px rgba(22, 75, 65, 0.4); transform: translateY(-2px); }
266
  .product-button i { margin-right: 5px; }
267
- .add-to-cart { background-color: #38a169; }
268
- .add-to-cart:hover { background-color: #2f855a; box-shadow: 0 4px 15px rgba(47, 133, 90, 0.4); }
269
- #cart-button { position: fixed; bottom: 25px; right: 25px; background-color: #1C6758; color: white; border: none; border-radius: 50%; width: 55px; height: 55px; font-size: 1.5rem; cursor: pointer; display: none; align-items: center; justify-content: center; box-shadow: 0 4px 15px rgba(28, 103, 88, 0.4); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 1000; }
270
  #cart-button .fa-shopping-cart { margin-right: 0; }
271
- #cart-button span { position: absolute; top: -5px; right: -5px; background-color: #38a169; color: white; border-radius: 50%; padding: 2px 6px; font-size: 0.7rem; font-weight: bold; }
272
  .modal { display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(5px); overflow-y: auto; }
273
- .modal-content { background: #f8fcfb; margin: 5% auto; padding: 25px; border-radius: 15px; width: 90%; max-width: 700px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); animation: slideIn 0.3s ease-out; position: relative; }
274
- body.dark-mode .modal-content { background: #253f37; color: #c8d8d3; }
275
  @keyframes slideIn { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
276
  .close { position: absolute; top: 15px; right: 15px; font-size: 1.8rem; color: #aaa; cursor: pointer; transition: color 0.3s; line-height: 1; }
277
  .close:hover { color: #333; }
278
- body.dark-mode .close { color: #7a8d85; }
279
- body.dark-mode .close:hover { color: #b0c8c1; }
280
- .modal-content h2 { margin-top: 0; margin-bottom: 20px; color: #1C6758; display: flex; align-items: center; gap: 10px;}
281
- body.dark-mode .modal-content h2 { color: #55a683; }
282
- .cart-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid #d1e7dd; }
283
- body.dark-mode .cart-item { border-bottom-color: #2c4a41; }
284
  .cart-item:last-child { border-bottom: none; }
285
  .cart-item img { width: 60px; height: 60px; object-fit: contain; border-radius: 8px; background-color: #fff; padding: 5px; grid-column: 1; }
286
  .cart-item-details { grid-column: 2; }
287
  .cart-item-details strong { display: block; margin-bottom: 5px; font-size: 1rem; }
288
- .cart-item-price { font-size: 0.9rem; color: #44524c; }
289
- body.dark-mode .cart-item-price { color: #8aa39a; }
290
  .cart-item-total { font-weight: bold; text-align: right; grid-column: 3; font-size: 1rem;}
291
  .cart-item-remove { grid-column: 4; background:none; border:none; color:#f56565; cursor:pointer; font-size: 1.3em; padding: 5px; line-height: 1; }
292
  .cart-item-remove:hover { color: #c53030; }
293
- .quantity-input, .color-select { width: 100%; max-width: 180px; padding: 10px; border: 1px solid #d1e7dd; border-radius: 8px; font-size: 1rem; margin: 10px 0; box-sizing: border-box; }
294
- body.dark-mode .quantity-input, body.dark-mode .color-select { background-color: #1a2b26; border-color: #2c4a41; color: #c8d8d3; }
295
- .cart-summary { margin-top: 20px; text-align: right; border-top: 1px solid #d1e7dd; padding-top: 15px; }
296
- body.dark-mode .cart-summary { border-top-color: #2c4a41; }
297
  .cart-summary strong { font-size: 1.2rem; }
298
  .cart-actions { margin-top: 25px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
299
  .cart-actions .product-button { width: auto; flex-grow: 1; }
300
  .clear-cart { background-color: #7a8d85; }
301
  .clear-cart:hover { background-color: #5e6e68; box-shadow: 0 4px 15px rgba(94, 110, 104, 0.4); }
302
- .formulate-order-button { background-color: #38a169; }
303
- .formulate-order-button:hover { background-color: #2f855a; box-shadow: 0 4px 15px rgba(47, 133, 90, 0.4); }
304
- .notification { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background-color: #38a169; color: white; padding: 10px 20px; border-radius: 20px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); z-index: 1002; opacity: 0; transition: opacity 0.5s ease; font-size: 0.9rem;}
305
  .notification.show { opacity: 1;}
306
  .no-results-message { grid-column: 1 / -1; text-align: center; padding: 40px; font-size: 1.1rem; color: #5e6e68; }
307
- body.dark-mode .no-results-message { color: #8aa39a; }
308
  .top-product-indicator { position: absolute; top: 8px; right: 8px; background-color: rgba(255, 215, 0, 0.8); color: #333; padding: 2px 6px; font-size: 0.7rem; border-radius: 4px; font-weight: bold; z-index: 10; backdrop-filter: blur(2px); }
309
  .product { position: relative; }
310
  </style>
@@ -312,10 +280,8 @@ CATALOG_TEMPLATE = '''
312
  <body>
313
  <div class="container">
314
  <div class="header">
315
- <h1>MedinaTurkey.kz</h1>
316
- <button class="theme-toggle" onclick="toggleTheme()" aria-label="Переключить тему">
317
- <i class="fas fa-moon"></i>
318
- </button>
319
  </div>
320
 
321
  <div class="store-address">Наш адрес: {{ store_address }}</div>
@@ -421,24 +387,6 @@ CATALOG_TEMPLATE = '''
421
  let selectedProductIndex = null;
422
  let cart = JSON.parse(localStorage.getItem('soolaCart') || '[]');
423
 
424
- function toggleTheme() {
425
- document.body.classList.toggle('dark-mode');
426
- const icon = document.querySelector('.theme-toggle i');
427
- const isDarkMode = document.body.classList.contains('dark-mode');
428
- icon.classList.toggle('fa-moon', !isDarkMode);
429
- icon.classList.toggle('fa-sun', isDarkMode);
430
- localStorage.setItem('soolaTheme', isDarkMode ? 'dark' : 'light');
431
- }
432
-
433
- function applyInitialTheme() {
434
- const savedTheme = localStorage.getItem('soolaTheme');
435
- if (savedTheme === 'dark') {
436
- document.body.classList.add('dark-mode');
437
- const icon = document.querySelector('.theme-toggle i');
438
- if (icon) icon.classList.replace('fa-moon', 'fa-sun');
439
- }
440
- }
441
-
442
  function openModal(index) {
443
  loadProductDetails(index);
444
  const modal = document.getElementById('productModal');
@@ -551,7 +499,7 @@ CATALOG_TEMPLATE = '''
551
  return;
552
  }
553
 
554
- const cartItemId = `${product.name}-${color}`; // Use name + color as ID
555
  const existingItemIndex = cart.findIndex(item => item.id === cartItemId);
556
 
557
  if (existingItemIndex > -1) {
@@ -777,7 +725,6 @@ CATALOG_TEMPLATE = '''
777
  }
778
 
779
  document.addEventListener('DOMContentLoaded', () => {
780
- applyInitialTheme();
781
  updateCartButton();
782
  setupFilters();
783
 
@@ -803,7 +750,7 @@ CATALOG_TEMPLATE = '''
803
 
804
  PRODUCT_DETAIL_TEMPLATE = '''
805
  <div style="padding: 10px;">
806
- <h2 style="font-size: 1.6rem; font-weight: 600; margin-bottom: 15px; text-align: center; color: #1C6758;">{{ product['name'] }}</h2>
807
  <div class="swiper-container" style="max-width: 450px; margin: 0 auto 20px; border-radius: 10px; overflow: hidden; background-color: #fff;">
808
  <div class="swiper-wrapper">
809
  {% if product.get('photos') and product['photos']|length > 0 %}
@@ -824,14 +771,14 @@ PRODUCT_DETAIL_TEMPLATE = '''
824
  </div>
825
  {% if product.get('photos') and product['photos']|length > 1 %}
826
  <div class="swiper-pagination" style="position: relative; bottom: 5px;"></div>
827
- <div class="swiper-button-next" style="color: #1C6758;"></div>
828
- <div class="swiper-button-prev" style="color: #1C6758;"></div>
829
  {% endif %}
830
  </div>
831
 
832
  <div style="margin-top: 20px; font-size: 1rem; line-height: 1.7;">
833
  <p><strong>Категория:</strong> {{ product.get('category', 'Без категории') }}</p>
834
- <p style="font-size: 1.2rem; font-weight: bold; color: #1C6758;"><strong>Цена:</strong> {{ "%.2f"|format(product['price']) }} {{ currency_code }}</p>
835
  <p><strong>Описание:</strong><br> {{ product.get('description', 'Описание отсутствует.')|replace('\\n', '<br>')|safe }}</p>
836
  {% set colors = product.get('colors', []) %}
837
  {% if colors and colors|select('ne', '')|list|length > 0 %}
@@ -847,33 +794,35 @@ ORDER_TEMPLATE = '''
847
  <head>
848
  <meta charset="UTF-8">
849
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
850
- <title>Заказ №{{ order.id }} - MedinaTurkey.kz</title>
851
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
852
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
853
  <style>
854
- body { font-family: 'Poppins', sans-serif; background: #f0f9f4; color: #2d332f; line-height: 1.6; padding: 20px; }
855
- .container { max-width: 800px; margin: 20px auto; padding: 30px; background: #fff; border-radius: 15px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); border: 1px solid #d1e7dd; }
856
- h1 { text-align: center; color: #1C6758; margin-bottom: 25px; font-size: 1.8rem; font-weight: 600; }
857
- h2 { color: #164B41; margin-top: 30px; margin-bottom: 15px; font-size: 1.4rem; border-bottom: 1px solid #d1e7dd; padding-bottom: 8px;}
858
  .order-meta { font-size: 0.9rem; color: #5e6e68; margin-bottom: 20px; text-align: center; }
859
- .order-item { display: grid; grid-template-columns: 60px 1fr auto; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid #e1f0e9; }
860
  .order-item:last-child { border-bottom: none; }
861
- .order-item img { width: 60px; height: 60px; object-fit: contain; border-radius: 8px; background-color: #fff; padding: 5px; border: 1px solid #e1f0e9;}
862
- .item-details strong { display: block; margin-bottom: 5px; font-size: 1.05rem; color: #2d332f;}
863
- .item-details span { font-size: 0.9rem; color: #44524c; display: block;}
864
- .item-total { font-weight: bold; text-align: right; font-size: 1rem; color: #1C6758;}
865
- .order-summary { margin-top: 30px; padding-top: 20px; border-top: 2px solid #1C6758; text-align: right; }
866
  .order-summary p { margin-bottom: 10px; font-size: 1.1rem; }
867
- .order-summary strong { font-size: 1.3rem; color: #1C6758; }
868
- .customer-info { margin-top: 30px; background-color: #f8fcfb; padding: 20px; border-radius: 8px; border: 1px solid #e1f0e9;}
869
  .customer-info p { margin-bottom: 8px; font-size: 0.95rem; }
870
- .customer-info strong { color: #164B41; }
871
- .actions { margin-top: 30px; text-align: center; }
872
- .button { padding: 12px 25px; border: none; border-radius: 8px; background-color: #25D366; color: white; font-weight: 600; cursor: pointer; transition: background-color 0.3s ease, transform 0.1s ease; font-size: 1rem; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
873
- .button:hover { background-color: #128C7E; }
874
  .button:active { transform: scale(0.98); }
875
  .button i { font-size: 1.2rem; }
876
- .catalog-link { display: block; text-align: center; margin-top: 25px; color: #3D8361; text-decoration: none; font-size: 0.9rem; }
 
 
877
  .catalog-link:hover { text-decoration: underline; }
878
  .not-found { text-align: center; color: #c53030; font-size: 1.2rem; padding: 40px 0;}
879
  </style>
@@ -908,11 +857,12 @@ ORDER_TEMPLATE = '''
908
  <div class="customer-info">
909
  <h2><i class="fas fa-info-circle"></i> Статус заказа</h2>
910
  <p>Этот заказ был оформлен без входа в систему.</p>
911
- <p>Пожалуйста, свяжитесь с нами по WhatsApp для подтверждения и уточнения деталей.</p>
912
  </div>
913
 
914
  <div class="actions">
915
- <button class="button" onclick="sendOrderViaWhatsApp()"><i class="fab fa-whatsapp"></i> Отправить заказ</button>
 
916
  </div>
917
 
918
  <a href="{{ url_for('catalog') }}" class="catalog-link">← Вернуться в каталог</a>
@@ -921,9 +871,9 @@ ORDER_TEMPLATE = '''
921
  function sendOrderViaWhatsApp() {
922
  const orderId = '{{ order.id }}';
923
  const orderUrl = `{{ request.url }}`;
924
- const whatsappNumber = "77479003212";
925
 
926
- let message = `Здравствуйте! Хочу подтвердить свой заказ на MedinaTurkey.kz:%0A%0A`;
927
  message += `*Номер заказа:* ${orderId}%0A`;
928
  message += `*Ссылка на заказ:* ${encodeURIComponent(orderUrl)}%0A%0A`;
929
  message += `Пожалуйста, свяжитесь со мной для уточнения деталей оплаты и доставки.`;
@@ -949,49 +899,49 @@ ADMIN_TEMPLATE = '''
949
  <head>
950
  <meta charset="UTF-8">
951
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
952
- <title>Админ-панель - MedinaTurkey.kz</title>
953
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
954
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
955
  <style>
956
- body { font-family: 'Poppins', sans-serif; background-color: #e9f5f0; color: #2d332f; padding: 20px; line-height: 1.6; }
957
  .container { max-width: 1200px; margin: 0 auto; background-color: #fff; padding: 25px; border-radius: 10px; box-shadow: 0 3px 10px rgba(0,0,0,0.05); }
958
- .header { padding-bottom: 15px; margin-bottom: 25px; border-bottom: 1px solid #d1e7dd; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;}
959
- h1, h2, h3 { font-weight: 600; color: #1C6758; margin-bottom: 15px; }
960
  h1 { font-size: 1.8rem; }
961
  h2 { font-size: 1.5rem; margin-top: 30px; display: flex; align-items: center; gap: 8px; }
962
- h3 { font-size: 1.2rem; color: #164B41; margin-top: 20px; }
963
- .section { margin-bottom: 30px; padding: 20px; background-color: #f8fcfb; border: 1px solid #d1e7dd; border-radius: 8px; }
964
  form { margin-bottom: 20px; }
965
  label { font-weight: 500; margin-top: 10px; display: block; color: #44524c; font-size: 0.9rem;}
966
  input[type="text"], input[type="number"], input[type="password"], input[type="tel"], textarea, select { width: 100%; padding: 10px 12px; margin-top: 5px; border: 1px solid #c4d9d1; border-radius: 6px; font-size: 0.95rem; box-sizing: border-box; transition: border-color 0.3s ease; }
967
- input:focus, textarea:focus, select:focus { border-color: #1C6758; outline: none; box-shadow: 0 0 0 2px rgba(28, 103, 88, 0.1); }
968
  textarea { min-height: 80px; resize: vertical; }
969
- input[type="file"] { padding: 8px; background-color: #f0f9f4; cursor: pointer; border: 1px solid #c4d9d1;}
970
- input[type="file"]::file-selector-button { padding: 5px 10px; border-radius: 4px; background-color: #e0f0e9; border: 1px solid #c4d9d1; cursor: pointer; margin-right: 10px;}
971
  input[type="checkbox"] { margin-right: 5px; vertical-align: middle; }
972
  label.inline-label { display: inline-block; margin-top: 10px; font-weight: normal; }
973
- button, .button { padding: 10px 18px; border: none; border-radius: 6px; background-color: #1C6758; color: white; font-weight: 500; cursor: pointer; transition: background-color 0.3s ease, transform 0.1s ease; margin-top: 15px; font-size: 0.95rem; display: inline-flex; align-items: center; gap: 5px; text-decoration: none; line-height: 1.2;}
974
- button:hover, .button:hover { background-color: #164B41; }
975
  button:active, .button:active { transform: scale(0.98); }
976
  button[type="submit"] { min-width: 120px; justify-content: center; }
977
  .delete-button { background-color: #f56565; }
978
  .delete-button:hover { background-color: #e53e3e; }
979
- .add-button { background-color: #38a169; }
980
- .add-button:hover { background-color: #2f855a; }
981
  .item-list { display: grid; gap: 20px; }
982
- .item { background: #fff; padding: 15px 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.07); border: 1px solid #e1f0e9; }
983
  .item p { margin: 5px 0; font-size: 0.9rem; color: #44524c; }
984
  .item strong { color: #2d332f; }
985
  .item .description { font-size: 0.85rem; color: #5e6e68; max-height: 60px; overflow: hidden; text-overflow: ellipsis; }
986
  .item-actions { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
987
- .item-actions button:not(.delete-button) { background-color: #1C6758; }
988
- .item-actions button:not(.delete-button):hover { background-color: #164B41; }
989
- .edit-form-container { margin-top: 15px; padding: 20px; background: #f0f9f4; border: 1px dashed #c4d9d1; border-radius: 6px; display: none; }
990
- details { background-color: #f8fcfb; border: 1px solid #d1e7dd; border-radius: 8px; margin-bottom: 20px; }
991
- details > summary { cursor: pointer; font-weight: 600; color: #164B41; display: block; padding: 15px; border-bottom: 1px solid #d1e7dd; list-style: none; position: relative; }
992
- details > summary::after { content: '\\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; right: 20px; top: 50%; transform: translateY(-50%); transition: transform 0.2s ease; color: #1C6758; }
993
  details[open] > summary::after { transform: translateY(-50%) rotate(180deg); }
994
- details[open] > summary { border-bottom: 1px solid #d1e7dd; }
995
  details .form-content { padding: 20px; }
996
  .color-input-group { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
997
  .color-input-group input { flex-grow: 1; margin: 0; }
@@ -999,7 +949,7 @@ ADMIN_TEMPLATE = '''
999
  .remove-color-btn:hover { background-color: #e53e3e; }
1000
  .add-color-btn { background-color: #63b3ed; }
1001
  .add-color-btn:hover { background-color: #4299e1; }
1002
- .photo-preview img { max-width: 70px; max-height: 70px; border-radius: 5px; margin: 5px 5px 0 0; border: 1px solid #d1e7dd; object-fit: cover;}
1003
  .sync-buttons { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
1004
  .download-hf-button { background-color: #7a8d85; }
1005
  .download-hf-button:hover { background-color: #5e6e68; }
@@ -1018,8 +968,8 @@ ADMIN_TEMPLATE = '''
1018
  <body>
1019
  <div class="container">
1020
  <div class="header">
1021
- <h1><i class="fas fa-tools"></i> Админ-панель MedinaTurkey.kz</h1>
1022
- <a href="{{ url_for('catalog') }}" class="button" style="background-color: #3D8361;"><i class="fas fa-store"></i> Перейти в каталог</a>
1023
  </div>
1024
 
1025
  {% with messages = get_flashed_messages(with_categories=true) %}
@@ -1083,7 +1033,7 @@ ADMIN_TEMPLATE = '''
1083
  <div class="section">
1084
  <h2><i class="fas fa-info-circle"></i> Информация</h2>
1085
  <p>Управление пользователями отключено, так как сайт не требует входа.</p>
1086
- <p>Заказы создаются анонимно и должны быть подтверждены через WhatsApp.</p>
1087
  </div>
1088
  </div>
1089
  </div>
@@ -1299,8 +1249,6 @@ ADMIN_TEMPLATE = '''
1299
  </html>
1300
  '''
1301
 
1302
- # --- Flask Routes ---
1303
-
1304
  @app.route('/')
1305
  def catalog():
1306
  data = load_data()
@@ -1381,7 +1329,7 @@ def create_order():
1381
  "created_at": order_timestamp,
1382
  "cart": processed_cart,
1383
  "total_price": round(total_price, 2),
1384
- "user_info": None, # Explicitly set to None as users are anonymous
1385
  "status": "new"
1386
  }
1387
 
@@ -1709,7 +1657,6 @@ def admin():
1709
  flash(f"Произошла внутренняя ошибка при выполнении действия '{action}'. Подробности в логе сервера.", 'error')
1710
  return redirect(url_for('admin'))
1711
 
1712
- # --- GET request ---
1713
  current_data = load_data()
1714
  display_products = sorted(current_data.get('products', []), key=lambda p: p.get('name', '').lower())
1715
  display_categories = sorted(current_data.get('categories', []))
@@ -1739,7 +1686,7 @@ def force_download():
1739
  try:
1740
  if download_db_from_hf():
1741
  flash("Данные успешно скачаны с Hugging Face. Локальные файлы обновлены.", 'success')
1742
- load_data() # Reload data in memory after download
1743
  else:
1744
  flash("Не удалось скачать данные с Hugging Face после нескольких попыток. Проверьте логи.", 'error')
1745
  except Exception as e:
@@ -1747,9 +1694,6 @@ def force_download():
1747
  flash(f"Ошибка при скачивании с Hugging Face: {e}", 'error')
1748
  return redirect(url_for('admin'))
1749
 
1750
-
1751
- # --- App Initialization ---
1752
-
1753
  if __name__ == '__main__':
1754
  logging.info("Application starting up. Performing initial data load/download...")
1755
  download_db_from_hf()
 
18
  load_dotenv()
19
 
20
  app = Flask(__name__)
21
+ app.secret_key = 'your_unique_secret_key_big_ben_12345_no_login'
22
  DATA_FILE = 'data.json'
23
 
 
24
  SYNC_FILES = [DATA_FILE]
25
 
26
+ REPO_ID = "Kgshop/bigben"
27
  HF_TOKEN_WRITE = os.getenv("HF_TOKEN")
28
  HF_TOKEN_READ = os.getenv("HF_TOKEN_READ")
29
 
30
+ STORE_ADDRESS = "ТД Саламат 4 ,этаж 1 , бутик 9"
31
 
32
  CURRENCY_CODE = 'KZT'
33
  CURRENCY_NAME = 'Казахский тенге'
34
 
35
  DOWNLOAD_RETRIES = 3
36
+ DOWNLOAD_DELAY = 5
37
 
38
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
39
 
 
 
40
  def download_db_from_hf(specific_file=None, retries=DOWNLOAD_RETRIES, delay=DOWNLOAD_DELAY):
41
  if not HF_TOKEN_READ and not HF_TOKEN_WRITE:
42
  logging.warning("HF_TOKEN_READ/HF_TOKEN_WRITE not set. Download might fail for private repos.")
 
136
  upload_db_to_hf()
137
  logging.info("Periodic backup finished.")
138
 
 
 
139
  def load_data():
140
  default_data = {'products': [], 'categories': [], 'orders': {}}
141
  try:
 
202
  except Exception as e:
203
  logging.error(f"Error saving data to {DATA_FILE}: {e}", exc_info=True)
204
 
 
 
205
  CATALOG_TEMPLATE = '''
206
  <!DOCTYPE html>
207
  <html lang="ru">
208
  <head>
209
  <meta charset="UTF-8">
210
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
211
+ <title>BIG BEN - Каталог</title>
212
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
213
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
214
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/10.2.0/swiper-bundle.min.css">
215
  <style>
216
  * { margin: 0; padding: 0; box-sizing: border-box; }
217
+ body { font-family: 'Poppins', sans-serif; background: #f4f6f7; color: #333; line-height: 1.6; }
 
218
  .container { max-width: 1300px; margin: 0 auto; padding: 20px; }
219
+ .header { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid #cdd5da; }
220
+ .header h1 { font-size: 1.8rem; font-weight: 600; color: #577f91; }
221
+ .store-address { padding: 15px; text-align: center; background-color: #ffffff; margin: 20px 0; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); font-size: 1rem; color: #4a6b7b; }
 
 
 
 
 
 
222
  .filters-container { margin: 20px 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
223
  .search-container { margin: 20px 0; text-align: center; }
224
+ #search-input { width: 90%; max-width: 600px; padding: 12px 18px; font-size: 1rem; border: 1px solid #cdd5da; border-radius: 25px; outline: none; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: all 0.3s ease; }
225
+ #search-input:focus { border-color: #577f91; box-shadow: 0 0 0 3px rgba(87, 127, 145, 0.2); }
226
+ .category-filter { padding: 8px 16px; border: 1px solid #cdd5da; border-radius: 20px; background-color: #fff; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); font-size: 0.9rem; font-weight: 400; color: #577f91; }
227
+ .category-filter.active, .category-filter:hover { background-color: #577f91; color: white; border-color: #577f91; box-shadow: 0 2px 10px rgba(87, 127, 145, 0.3); }
 
 
 
 
228
  .products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px; padding: 10px; }
229
  @media (min-width: 600px) { .products-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
230
  @media (min-width: 900px) { .products-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); } }
231
 
232
+ .product { background: #fff; border-radius: 15px; padding: 0; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; height: 100%; border: 1px solid #e0e6e9;}
 
233
  .product:hover { transform: translateY(-5px) scale(1.02); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); }
 
234
  .product-image { width: 100%; aspect-ratio: 1 / 1; background-color: #fff; border-radius: 10px 10px 0 0; overflow: hidden; display: flex; justify-content: center; align-items: center; margin-bottom: 0; }
235
  .product-image img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.3s ease; }
236
  .product-info { padding: 15px; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
237
+ .product h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 8px 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #333; }
238
+ .product-price { font-size: 1.2rem; color: #577f91; font-weight: 700; text-align: center; margin: 5px 0; }
239
+ .product-description { font-size: 0.85rem; color: #777; text-align: center; margin-bottom: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
 
 
 
240
  .product-actions { padding: 0 15px 15px 15px; display: flex; flex-direction: column; gap: 8px; }
241
+ .product-button { display: block; width: 100%; padding: 10px; border: none; border-radius: 8px; background-color: #577f91; color: white; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); text-align: center; text-decoration: none; }
242
+ .product-button:hover { background-color: #4a6b7b; box-shadow: 0 4px 15px rgba(74, 107, 123, 0.4); transform: translateY(-2px); }
243
  .product-button i { margin-right: 5px; }
244
+ .add-to-cart { background-color: #577f91; }
245
+ .add-to-cart:hover { background-color: #4a6b7b; box-shadow: 0 4px 15px rgba(74, 107, 123, 0.4); }
246
+ #cart-button { position: fixed; bottom: 25px; right: 25px; background-color: #577f91; color: white; border: none; border-radius: 50%; width: 55px; height: 55px; font-size: 1.5rem; cursor: pointer; display: none; align-items: center; justify-content: center; box-shadow: 0 4px 15px rgba(87, 127, 145, 0.4); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 1000; }
247
  #cart-button .fa-shopping-cart { margin-right: 0; }
248
+ #cart-button span { position: absolute; top: -5px; right: -5px; background-color: #4a6b7b; color: white; border-radius: 50%; padding: 2px 6px; font-size: 0.7rem; font-weight: bold; }
249
  .modal { display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(5px); overflow-y: auto; }
250
+ .modal-content { background: #ffffff; margin: 5% auto; padding: 25px; border-radius: 15px; width: 90%; max-width: 700px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); animation: slideIn 0.3s ease-out; position: relative; }
 
251
  @keyframes slideIn { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
252
  .close { position: absolute; top: 15px; right: 15px; font-size: 1.8rem; color: #aaa; cursor: pointer; transition: color 0.3s; line-height: 1; }
253
  .close:hover { color: #333; }
254
+ .modal-content h2 { margin-top: 0; margin-bottom: 20px; color: #577f91; display: flex; align-items: center; gap: 10px;}
255
+ .cart-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid #cdd5da; }
 
 
 
 
256
  .cart-item:last-child { border-bottom: none; }
257
  .cart-item img { width: 60px; height: 60px; object-fit: contain; border-radius: 8px; background-color: #fff; padding: 5px; grid-column: 1; }
258
  .cart-item-details { grid-column: 2; }
259
  .cart-item-details strong { display: block; margin-bottom: 5px; font-size: 1rem; }
260
+ .cart-item-price { font-size: 0.9rem; color: #555; }
 
261
  .cart-item-total { font-weight: bold; text-align: right; grid-column: 3; font-size: 1rem;}
262
  .cart-item-remove { grid-column: 4; background:none; border:none; color:#f56565; cursor:pointer; font-size: 1.3em; padding: 5px; line-height: 1; }
263
  .cart-item-remove:hover { color: #c53030; }
264
+ .quantity-input, .color-select { width: 100%; max-width: 180px; padding: 10px; border: 1px solid #cdd5da; border-radius: 8px; font-size: 1rem; margin: 10px 0; box-sizing: border-box; }
265
+ .cart-summary { margin-top: 20px; text-align: right; border-top: 1px solid #cdd5da; padding-top: 15px; }
 
 
266
  .cart-summary strong { font-size: 1.2rem; }
267
  .cart-actions { margin-top: 25px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
268
  .cart-actions .product-button { width: auto; flex-grow: 1; }
269
  .clear-cart { background-color: #7a8d85; }
270
  .clear-cart:hover { background-color: #5e6e68; box-shadow: 0 4px 15px rgba(94, 110, 104, 0.4); }
271
+ .formulate-order-button { background-color: #577f91; }
272
+ .formulate-order-button:hover { background-color: #4a6b7b; box-shadow: 0 4px 15px rgba(74, 107, 123, 0.4); }
273
+ .notification { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background-color: #4a6b7b; color: white; padding: 10px 20px; border-radius: 20px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); z-index: 1002; opacity: 0; transition: opacity 0.5s ease; font-size: 0.9rem;}
274
  .notification.show { opacity: 1;}
275
  .no-results-message { grid-column: 1 / -1; text-align: center; padding: 40px; font-size: 1.1rem; color: #5e6e68; }
 
276
  .top-product-indicator { position: absolute; top: 8px; right: 8px; background-color: rgba(255, 215, 0, 0.8); color: #333; padding: 2px 6px; font-size: 0.7rem; border-radius: 4px; font-weight: bold; z-index: 10; backdrop-filter: blur(2px); }
277
  .product { position: relative; }
278
  </style>
 
280
  <body>
281
  <div class="container">
282
  <div class="header">
283
+ <h1>BIG BEN</h1>
284
+
 
 
285
  </div>
286
 
287
  <div class="store-address">Наш адрес: {{ store_address }}</div>
 
387
  let selectedProductIndex = null;
388
  let cart = JSON.parse(localStorage.getItem('soolaCart') || '[]');
389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  function openModal(index) {
391
  loadProductDetails(index);
392
  const modal = document.getElementById('productModal');
 
499
  return;
500
  }
501
 
502
+ const cartItemId = `${product.name}-${color}`;
503
  const existingItemIndex = cart.findIndex(item => item.id === cartItemId);
504
 
505
  if (existingItemIndex > -1) {
 
725
  }
726
 
727
  document.addEventListener('DOMContentLoaded', () => {
 
728
  updateCartButton();
729
  setupFilters();
730
 
 
750
 
751
  PRODUCT_DETAIL_TEMPLATE = '''
752
  <div style="padding: 10px;">
753
+ <h2 style="font-size: 1.6rem; font-weight: 600; margin-bottom: 15px; text-align: center; color: #577f91;">{{ product['name'] }}</h2>
754
  <div class="swiper-container" style="max-width: 450px; margin: 0 auto 20px; border-radius: 10px; overflow: hidden; background-color: #fff;">
755
  <div class="swiper-wrapper">
756
  {% if product.get('photos') and product['photos']|length > 0 %}
 
771
  </div>
772
  {% if product.get('photos') and product['photos']|length > 1 %}
773
  <div class="swiper-pagination" style="position: relative; bottom: 5px;"></div>
774
+ <div class="swiper-button-next" style="color: #577f91;"></div>
775
+ <div class="swiper-button-prev" style="color: #577f91;"></div>
776
  {% endif %}
777
  </div>
778
 
779
  <div style="margin-top: 20px; font-size: 1rem; line-height: 1.7;">
780
  <p><strong>Категория:</strong> {{ product.get('category', 'Без категории') }}</p>
781
+ <p style="font-size: 1.2rem; font-weight: bold; color: #577f91;"><strong>Цена:</strong> {{ "%.2f"|format(product['price']) }} {{ currency_code }}</p>
782
  <p><strong>Описание:</strong><br> {{ product.get('description', 'Описание отсутствует.')|replace('\\n', '<br>')|safe }}</p>
783
  {% set colors = product.get('colors', []) %}
784
  {% if colors and colors|select('ne', '')|list|length > 0 %}
 
794
  <head>
795
  <meta charset="UTF-8">
796
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
797
+ <title>Заказ №{{ order.id }} - BIG BEN</title>
798
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
799
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
800
  <style>
801
+ body { font-family: 'Poppins', sans-serif; background: #f4f6f7; color: #333; line-height: 1.6; padding: 20px; }
802
+ .container { max-width: 800px; margin: 20px auto; padding: 30px; background: #fff; border-radius: 15px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); border: 1px solid #cdd5da; }
803
+ h1 { text-align: center; color: #577f91; margin-bottom: 25px; font-size: 1.8rem; font-weight: 600; }
804
+ h2 { color: #4a6b7b; margin-top: 30px; margin-bottom: 15px; font-size: 1.4rem; border-bottom: 1px solid #cdd5da; padding-bottom: 8px;}
805
  .order-meta { font-size: 0.9rem; color: #5e6e68; margin-bottom: 20px; text-align: center; }
806
+ .order-item { display: grid; grid-template-columns: 60px 1fr auto; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid #e0e6e9; }
807
  .order-item:last-child { border-bottom: none; }
808
+ .order-item img { width: 60px; height: 60px; object-fit: contain; border-radius: 8px; background-color: #fff; padding: 5px; border: 1px solid #e0e6e9;}
809
+ .item-details strong { display: block; margin-bottom: 5px; font-size: 1.05rem; color: #333;}
810
+ .item-details span { font-size: 0.9rem; color: #555; display: block;}
811
+ .item-total { font-weight: bold; text-align: right; font-size: 1rem; color: #577f91;}
812
+ .order-summary { margin-top: 30px; padding-top: 20px; border-top: 2px solid #577f91; text-align: right; }
813
  .order-summary p { margin-bottom: 10px; font-size: 1.1rem; }
814
+ .order-summary strong { font-size: 1.3rem; color: #577f91; }
815
+ .customer-info { margin-top: 30px; background-color: #f8fafd; padding: 20px; border-radius: 8px; border: 1px solid #e0e6e9;}
816
  .customer-info p { margin-bottom: 8px; font-size: 0.95rem; }
817
+ .customer-info strong { color: #4a6b7b; }
818
+ .actions { margin-top: 30px; text-align: center; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
819
+ .button { padding: 12px 25px; border: none; border-radius: 8px; background-color: #577f91; color: white; font-weight: 600; cursor: pointer; transition: background-color 0.3s ease, transform 0.1s ease; font-size: 1rem; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
820
+ .button:hover { background-color: #4a6b7b; }
821
  .button:active { transform: scale(0.98); }
822
  .button i { font-size: 1.2rem; }
823
+ .whatsapp-button { background-color: #25D366; }
824
+ .whatsapp-button:hover { background-color: #128C7E; }
825
+ .catalog-link { display: block; text-align: center; margin-top: 25px; color: #577f91; text-decoration: none; font-size: 0.9rem; }
826
  .catalog-link:hover { text-decoration: underline; }
827
  .not-found { text-align: center; color: #c53030; font-size: 1.2rem; padding: 40px 0;}
828
  </style>
 
857
  <div class="customer-info">
858
  <h2><i class="fas fa-info-circle"></i> Статус заказа</h2>
859
  <p>Этот заказ был оформлен без входа в систему.</p>
860
+ <p>Пожалуйста, свяжитесь с нами для подтверждения и уточнения деталей.</p>
861
  </div>
862
 
863
  <div class="actions">
864
+ <button class="button whatsapp-button" onclick="sendOrderViaWhatsApp()"><i class="fab fa-whatsapp"></i> Отправить в WhatsApp</button>
865
+ <a href="tel:+77273794453" class="button phone-button"><i class="fas fa-phone"></i> Позвонить</a>
866
  </div>
867
 
868
  <a href="{{ url_for('catalog') }}" class="catalog-link">← Вернуться в каталог</a>
 
871
  function sendOrderViaWhatsApp() {
872
  const orderId = '{{ order.id }}';
873
  const orderUrl = `{{ request.url }}`;
874
+ const whatsappNumber = "77080707006";
875
 
876
+ let message = `Здравствуйте! Хочу подтвердить свой заказ в BIG BEN:%0A%0A`;
877
  message += `*Номер заказа:* ${orderId}%0A`;
878
  message += `*Ссылка на заказ:* ${encodeURIComponent(orderUrl)}%0A%0A`;
879
  message += `Пожалуйста, свяжитесь со мной для уточнения деталей оплаты и доставки.`;
 
899
  <head>
900
  <meta charset="UTF-8">
901
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
902
+ <title>Админ-панель - BIG BEN</title>
903
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
904
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
905
  <style>
906
+ body { font-family: 'Poppins', sans-serif; background-color: #eaf0f2; color: #333; padding: 20px; line-height: 1.6; }
907
  .container { max-width: 1200px; margin: 0 auto; background-color: #fff; padding: 25px; border-radius: 10px; box-shadow: 0 3px 10px rgba(0,0,0,0.05); }
908
+ .header { padding-bottom: 15px; margin-bottom: 25px; border-bottom: 1px solid #cdd5da; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;}
909
+ h1, h2, h3 { font-weight: 600; color: #577f91; margin-bottom: 15px; }
910
  h1 { font-size: 1.8rem; }
911
  h2 { font-size: 1.5rem; margin-top: 30px; display: flex; align-items: center; gap: 8px; }
912
+ h3 { font-size: 1.2rem; color: #4a6b7b; margin-top: 20px; }
913
+ .section { margin-bottom: 30px; padding: 20px; background-color: #f8fafd; border: 1px solid #cdd5da; border-radius: 8px; }
914
  form { margin-bottom: 20px; }
915
  label { font-weight: 500; margin-top: 10px; display: block; color: #44524c; font-size: 0.9rem;}
916
  input[type="text"], input[type="number"], input[type="password"], input[type="tel"], textarea, select { width: 100%; padding: 10px 12px; margin-top: 5px; border: 1px solid #c4d9d1; border-radius: 6px; font-size: 0.95rem; box-sizing: border-box; transition: border-color 0.3s ease; }
917
+ input:focus, textarea:focus, select:focus { border-color: #577f91; outline: none; box-shadow: 0 0 0 2px rgba(87, 127, 145, 0.1); }
918
  textarea { min-height: 80px; resize: vertical; }
919
+ input[type="file"] { padding: 8px; background-color: #eaf0f2; cursor: pointer; border: 1px solid #c4d9d1;}
920
+ input[type="file"]::file-selector-button { padding: 5px 10px; border-radius: 4px; background-color: #dbe4e8; border: 1px solid #c4d9d1; cursor: pointer; margin-right: 10px;}
921
  input[type="checkbox"] { margin-right: 5px; vertical-align: middle; }
922
  label.inline-label { display: inline-block; margin-top: 10px; font-weight: normal; }
923
+ button, .button { padding: 10px 18px; border: none; border-radius: 6px; background-color: #577f91; color: white; font-weight: 500; cursor: pointer; transition: background-color 0.3s ease, transform 0.1s ease; margin-top: 15px; font-size: 0.95rem; display: inline-flex; align-items: center; gap: 5px; text-decoration: none; line-height: 1.2;}
924
+ button:hover, .button:hover { background-color: #4a6b7b; }
925
  button:active, .button:active { transform: scale(0.98); }
926
  button[type="submit"] { min-width: 120px; justify-content: center; }
927
  .delete-button { background-color: #f56565; }
928
  .delete-button:hover { background-color: #e53e3e; }
929
+ .add-button { background-color: #577f91; } /* Changed from green */
930
+ .add-button:hover { background-color: #4a6b7b; }
931
  .item-list { display: grid; gap: 20px; }
932
+ .item { background: #fff; padding: 15px 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.07); border: 1px solid #e0e6e9; }
933
  .item p { margin: 5px 0; font-size: 0.9rem; color: #44524c; }
934
  .item strong { color: #2d332f; }
935
  .item .description { font-size: 0.85rem; color: #5e6e68; max-height: 60px; overflow: hidden; text-overflow: ellipsis; }
936
  .item-actions { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
937
+ .item-actions button:not(.delete-button) { background-color: #577f91; }
938
+ .item-actions button:not(.delete-button):hover { background-color: #4a6b7b; }
939
+ .edit-form-container { margin-top: 15px; padding: 20px; background: #eaf0f2; border: 1px dashed #c4d9d1; border-radius: 6px; display: none; }
940
+ details { background-color: #f8fafd; border: 1px solid #cdd5da; border-radius: 8px; margin-bottom: 20px; }
941
+ details > summary { cursor: pointer; font-weight: 600; color: #4a6b7b; display: block; padding: 15px; border-bottom: 1px solid #cdd5da; list-style: none; position: relative; }
942
+ details > summary::after { content: '\\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; right: 20px; top: 50%; transform: translateY(-50%); transition: transform 0.2s ease; color: #577f91; }
943
  details[open] > summary::after { transform: translateY(-50%) rotate(180deg); }
944
+ details[open] > summary { border-bottom: 1px solid #cdd5da; }
945
  details .form-content { padding: 20px; }
946
  .color-input-group { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
947
  .color-input-group input { flex-grow: 1; margin: 0; }
 
949
  .remove-color-btn:hover { background-color: #e53e3e; }
950
  .add-color-btn { background-color: #63b3ed; }
951
  .add-color-btn:hover { background-color: #4299e1; }
952
+ .photo-preview img { max-width: 70px; max-height: 70px; border-radius: 5px; margin: 5px 5px 0 0; border: 1px solid #cdd5da; object-fit: cover;}
953
  .sync-buttons { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
954
  .download-hf-button { background-color: #7a8d85; }
955
  .download-hf-button:hover { background-color: #5e6e68; }
 
968
  <body>
969
  <div class="container">
970
  <div class="header">
971
+ <h1><i class="fas fa-tools"></i> Админ-панель BIG BEN</h1>
972
+ <a href="{{ url_for('catalog') }}" class="button" style="background-color: #4a6b7b;"><i class="fas fa-store"></i> Перейти в каталог</a>
973
  </div>
974
 
975
  {% with messages = get_flashed_messages(with_categories=true) %}
 
1033
  <div class="section">
1034
  <h2><i class="fas fa-info-circle"></i> Информация</h2>
1035
  <p>Управление пользователями отключено, так как сайт не требует входа.</p>
1036
+ <p>Заказы создаются анонимно и должны быть подтверждены через WhatsApp (+77080707006) или по телефону (+77273794453).</p>
1037
  </div>
1038
  </div>
1039
  </div>
 
1249
  </html>
1250
  '''
1251
 
 
 
1252
  @app.route('/')
1253
  def catalog():
1254
  data = load_data()
 
1329
  "created_at": order_timestamp,
1330
  "cart": processed_cart,
1331
  "total_price": round(total_price, 2),
1332
+ "user_info": None,
1333
  "status": "new"
1334
  }
1335
 
 
1657
  flash(f"Произошла внутренняя ошибка при выполнении действия '{action}'. Подробности в логе сервера.", 'error')
1658
  return redirect(url_for('admin'))
1659
 
 
1660
  current_data = load_data()
1661
  display_products = sorted(current_data.get('products', []), key=lambda p: p.get('name', '').lower())
1662
  display_categories = sorted(current_data.get('categories', []))
 
1686
  try:
1687
  if download_db_from_hf():
1688
  flash("Данные успешно скачаны с Hugging Face. Локальные файлы обновлены.", 'success')
1689
+ load_data()
1690
  else:
1691
  flash("Не удалось скачать данные с Hugging Face после нескольких попыток. Проверьте логи.", 'error')
1692
  except Exception as e:
 
1694
  flash(f"Ошибка при скачивании с Hugging Face: {e}", 'error')
1695
  return redirect(url_for('admin'))
1696
 
 
 
 
1697
  if __name__ == '__main__':
1698
  logging.info("Application starting up. Performing initial data load/download...")
1699
  download_db_from_hf()