Обновлён: restoran_max_bot/settings.py — Добавлены настройки MEDIA_ROOT и MEDIA_URL для динамических файлов.

 Обновлён: restoran_max_bot/promo_handlers.py — Изменено сохранение QR-кодов в MEDIA_ROOT и формирование ссылок через MEDIA_URL.
 Обновлён: restoran_max_bot/command_handlers.py — Изменено сохранение QR-кодов для бонусов в MEDIA_ROOT и формирование ссылок через MEDIA_URL.
 Обновлён: restoran_max_bot/urls.py — Добавлена поддержка обслуживания медиафайлов через Django при DEBUG=True.
main
pilot 2 months ago
parent 0b007101f8
commit 005e85483e

@ -7,7 +7,7 @@ from restoran_max_bot.common import common_get_data, common_get_integration
from restoran_max_bot.iiko_api import customer_info, customer_create, customer_wallet from restoran_max_bot.iiko_api import customer_info, customer_create, customer_wallet
from restoran_max_bot.rkiper_api import rkiper_customer_info, rkiper_customer_create from restoran_max_bot.rkiper_api import rkiper_customer_info, rkiper_customer_create
from restoran_max_bot.message_sender import send_text, send_image, send_menu, send_feedback_buttons, send_booking_people_buttons, send_link_button from restoran_max_bot.message_sender import send_text, send_image, send_menu, send_feedback_buttons, send_booking_people_buttons, send_link_button
from restoran_max_bot.settings import BASE_URL, MEDIA_ROOT, MEDIA_URL from restoran_max_bot.settings import BASE_URL, MEDIA_ROOT, MEDIA_URL, STATICFILES_DIRS
from restoran_max_bot.utils import is_json from restoran_max_bot.utils import is_json
from restoran_max_bot.bot_started import check_registration from restoran_max_bot.bot_started import check_registration
from restoran_max_bot.promo_handlers import bot_promo from restoran_max_bot.promo_handlers import bot_promo
@ -110,10 +110,12 @@ def _handle_bonus(client: Client, chat_id: str, token: str, contact: Contact) ->
# Генерируем QR-код # Генерируем QR-код
img = qrcode.make(contact.phone) img = qrcode.make(contact.phone)
file_name = f"{contact.phone}.png" file_name = f"{contact.phone}.png"
client_qr_dir = os.path.join(MEDIA_ROOT, 'client_qr') # Сохраняем в статическую папку (как было изначально)
os.makedirs(client_qr_dir, exist_ok=True) img.save(f"{STATICFILES_DIRS[0]}/client_qr/{file_name}")
img.save(os.path.join(client_qr_dir, file_name)) # Формируем URL (жёстко, как работало раньше)
qr_url = f"{BASE_URL}{MEDIA_URL}client_qr/{file_name}" qr_url = f"https://maxbot.telefon-ip.ru/static/client_qr/{file_name}"
# Логируем для отладки
print(f"DEBUG BONUS QR URL: {qr_url}")
send_image(chat_id, token, qr_url, 'QR-код для начисления, списания бонусов.') send_image(chat_id, token, qr_url, 'QR-код для начисления, списания бонусов.')
# Получаем баланс # Получаем баланс

Loading…
Cancel
Save