From ceea14c711913f3c0576ebbe42d35fdb82ac59b5 Mon Sep 17 00:00:00 2001 From: pilot <657434@03b.ru> Date: Mon, 25 May 2026 08:03:16 +0800 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BD=D0=B5=D0=B4=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- restoran_max_bot/content_bot/__init__.py | 0 restoran_max_bot/content_bot/admin.py | 3 ++ restoran_max_bot/content_bot/apps.py | 6 ++++ .../content_bot/migrations/__init__.py | 0 restoran_max_bot/content_bot/models.py | 3 ++ restoran_max_bot/content_bot/tests.py | 3 ++ restoran_max_bot/content_bot/urls.py | 8 +++++ restoran_max_bot/content_bot/views.py | 31 +++++++++++++++++++ 8 files changed, 54 insertions(+) create mode 100644 restoran_max_bot/content_bot/__init__.py create mode 100644 restoran_max_bot/content_bot/admin.py create mode 100644 restoran_max_bot/content_bot/apps.py create mode 100644 restoran_max_bot/content_bot/migrations/__init__.py create mode 100644 restoran_max_bot/content_bot/models.py create mode 100644 restoran_max_bot/content_bot/tests.py create mode 100644 restoran_max_bot/content_bot/urls.py create mode 100644 restoran_max_bot/content_bot/views.py diff --git a/restoran_max_bot/content_bot/__init__.py b/restoran_max_bot/content_bot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/restoran_max_bot/content_bot/admin.py b/restoran_max_bot/content_bot/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/restoran_max_bot/content_bot/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/restoran_max_bot/content_bot/apps.py b/restoran_max_bot/content_bot/apps.py new file mode 100644 index 0000000..80d9648 --- /dev/null +++ b/restoran_max_bot/content_bot/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ContentBotConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'content_bot' diff --git a/restoran_max_bot/content_bot/migrations/__init__.py b/restoran_max_bot/content_bot/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/restoran_max_bot/content_bot/models.py b/restoran_max_bot/content_bot/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/restoran_max_bot/content_bot/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/restoran_max_bot/content_bot/tests.py b/restoran_max_bot/content_bot/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/restoran_max_bot/content_bot/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/restoran_max_bot/content_bot/urls.py b/restoran_max_bot/content_bot/urls.py new file mode 100644 index 0000000..86d0926 --- /dev/null +++ b/restoran_max_bot/content_bot/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from content_bot.views import api_default_load +from max_bot.views import api_start_max_v1, iiko_webhook, iiko_send_message + +urlpatterns = [ + path('default-load/', api_default_load), +] diff --git a/restoran_max_bot/content_bot/views.py b/restoran_max_bot/content_bot/views.py new file mode 100644 index 0000000..4f7cf0c --- /dev/null +++ b/restoran_max_bot/content_bot/views.py @@ -0,0 +1,31 @@ +from django.http import JsonResponse +from django.core.handlers.wsgi import WSGIRequest +from django.views.decorators.csrf import csrf_exempt + +from max_bot.models import Client, ProductCategory + + +# Create your views here. +@csrf_exempt +def api_default_load(request: WSGIRequest, token): + # получаем информацию по токену клиента и делаем проверку + client = Client.objects.filter(token=token).first() + if not client: + rt = {'success': False, 'error': 'Unauthorized token', 'data': {}} + return JsonResponse(rt, status=401) + + # делаем на базе клиента Тэнгис ID 50 + categorys = ProductCategory.objects.filter(client=50, src=1, status=1) + for category in categorys: + if not ProductCategory.objects.filter(client=client, src=1, status=1, title=category.title): + print(category.title) + new_category = ProductCategory.objects.create() + new_category.pk = None + new_category.client = client + new_category.save() + + + + + rt = {'success': False, 'data': ''} + return JsonResponse(rt, status=200)