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)