Compare commits

..

No commits in common. '0b007101f8cd61db50171075b419f681818e7dbb' and 'e29bdacb3eef6d7817ccb0c158d07164b82feb70' have entirely different histories.

@ -1,13 +1,12 @@
# command_handlers.py # command_handlers.py
import json import json
import qrcode import qrcode
import os
from max_bot.models import Client, Contact from max_bot.models import Client, Contact
from restoran_max_bot.common import common_get_data, common_get_integration 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 STATICFILES_DIRS, BASE_URL
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
@ -109,11 +108,8 @@ def _handle_bonus(client: Client, chat_id: str, token: str, contact: Contact) ->
"""Обработка команды бонусов: генерация QR и запрос баланса.""" """Обработка команды бонусов: генерация QR и запрос баланса."""
# Генерируем QR-код # Генерируем QR-код
img = qrcode.make(contact.phone) img = qrcode.make(contact.phone)
file_name = f"{contact.phone}.png" img.save(f"{STATICFILES_DIRS[0]}/client_qr/{contact.phone}.png")
client_qr_dir = os.path.join(MEDIA_ROOT, 'client_qr') qr_url = f"https://maxbot.telefon-ip.ru/static/client_qr/{contact.phone}.png"
os.makedirs(client_qr_dir, exist_ok=True)
img.save(os.path.join(client_qr_dir, file_name))
qr_url = f"{BASE_URL}{MEDIA_URL}client_qr/{file_name}"
send_image(chat_id, token, qr_url, 'QR-код для начисления, списания бонусов.') send_image(chat_id, token, qr_url, 'QR-код для начисления, списания бонусов.')
# Получаем баланс # Получаем баланс

@ -1,10 +1,9 @@
# promo_handlers.py # promo_handlers.py
import qrcode import qrcode
import os
from max_bot.models import Client, PromoCode from max_bot.models import Client, PromoCode
from restoran_max_bot.common import common_get_data from restoran_max_bot.common import common_get_data
from restoran_max_bot.message_sender import send_text, send_image from restoran_max_bot.message_sender import send_text, send_image
from restoran_max_bot.settings import BASE_URL, MEDIA_ROOT, MEDIA_URL from restoran_max_bot.settings import STATICFILES_DIRS, BASE_URL
from restoran_max_bot.user_logger import log_user_action from restoran_max_bot.user_logger import log_user_action
@ -69,13 +68,8 @@ def bot_promo(client: Client, message: dict, settings_max: dict) -> bool:
url_promo = f"{base_url}{promo}/{chat_id}/{client_id}" url_promo = f"{base_url}{promo}/{chat_id}/{client_id}"
img = qrcode.make(url_promo) img = qrcode.make(url_promo)
file_name = f"{promo}-{chat_id}-{client_id}.png" file_name = f"{promo}-{chat_id}-{client_id}.png"
img.save(f"{STATICFILES_DIRS[0]}/client_qr/{file_name}")
# Сохраняем в медиа-папку qr_url = f"{BASE_URL}/static/client_qr/{file_name}"
client_qr_dir = os.path.join(MEDIA_ROOT, 'client_qr')
os.makedirs(client_qr_dir, exist_ok=True)
img.save(os.path.join(client_qr_dir, file_name))
qr_url = f"{BASE_URL}{MEDIA_URL}client_qr/{file_name}"
# Выводим ссылки в консоль для отладки # Выводим ссылки в консоль для отладки
print(f"🔍 PROMO DEBUG: статус-ссылка = {url_promo}") print(f"🔍 PROMO DEBUG: статус-ссылка = {url_promo}")

@ -144,10 +144,6 @@ STATIC_URL = 'static/'
# Дополнительные директории для поиска статических файлов # Дополнительные директории для поиска статических файлов
STATICFILES_DIRS = [(os.path.join(BASE_DIR, "static"))] STATICFILES_DIRS = [(os.path.join(BASE_DIR, "static"))]
# Media files (user-uploaded and dynamically generated content)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field

@ -1,7 +1,5 @@
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from max_bot.views import promo_status, promo_activate from max_bot.views import promo_status, promo_activate
@ -12,7 +10,3 @@ urlpatterns = [
path('promo/status/<str:promo_code>/<str:chat_id>/<int:client_id>', promo_status), path('promo/status/<str:promo_code>/<str:chat_id>/<int:client_id>', promo_status),
path('promo/activate/<str:promo_code>/<str:chat_id>/<int:client_id>', promo_activate), path('promo/activate/<str:promo_code>/<str:chat_id>/<int:client_id>', promo_activate),
] ]
# Обслуживание медиафайлов в режиме разработки
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Loading…
Cancel
Save