Внедрение проекта

main
pilot 2 months ago
parent b3c53e5527
commit ceea14c711

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ContentBotConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'content_bot'

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

@ -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/<str:token>', api_default_load),
]

@ -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)
Loading…
Cancel
Save