From 0e474650e5e2f7fa7fdd626c3f4a0bcb3228405e Mon Sep 17 00:00:00 2001 From: Fynjy Date: Sun, 3 Dec 2023 12:01:33 +0200 Subject: [PATCH] =?UTF-8?q?=D0=B2=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B8=D1=82=D1=81=D1=8F?= =?UTF-8?q?=20=D0=B8=D0=BC=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F,=20=D1=81=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D0=B2=D1=88=D0=B5=D0=B3=D0=BE=20=D0=B7=D0=B0=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=20#19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminpanel/settings.py | 2 +- adminpanelapp/admin.py | 21 ++++++++++++++------- adminpanelapp/models.py | 26 ++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/adminpanel/settings.py b/adminpanel/settings.py index 282ae3a..b8723b7 100644 --- a/adminpanel/settings.py +++ b/adminpanel/settings.py @@ -24,7 +24,7 @@ load_dotenv() SECRET_KEY = os.getenv('PLATFORM_ADMINPANEL_SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False +DEBUG = True ALLOWED_HOSTS = ['*'] diff --git a/adminpanelapp/admin.py b/adminpanelapp/admin.py index 8f760f2..b7de0f2 100644 --- a/adminpanelapp/admin.py +++ b/adminpanelapp/admin.py @@ -2,7 +2,7 @@ from django.contrib.auth.models import User, Group from django.http import HttpResponseRedirect from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.utils.safestring import mark_safe -from .models import Orders +from .models import Orders, Users from django.contrib import admin, messages from django.urls import reverse @@ -10,6 +10,18 @@ from django.urls import reverse class OrdersAdmin(admin.ModelAdmin): + list_display = ( + 'orderName', 'orderCreateDateTime', 'orderDesc', 'orderAddress', + 'catID', 'userName', 'orderStatus', 'show_photo', 'show_photopay', + ) + actions = ['send_message'] + exclude = ['orderAccess', 'userID', 'orderPhoto', 'orderPhotoPay'] + + + def userName(self, obj): + user = Users.objects.get(user_id=obj.userID) + return user.userName + def changeform_view(self, request, object_id=None, form_url='', extra_context=None): extra_context = extra_context or {} @@ -22,10 +34,6 @@ class OrdersAdmin(admin.ModelAdmin): def has_add_permission(self, request): return False - list_display = ('orderName', 'orderCreateDateTime', 'orderDesc', 'orderAddress', 'show_photo', 'show_photopay') - actions =['send_message'] - exclude = ['orderAccess', 'userID', 'orderPhoto', 'orderPhotoPay'] - def show_photo(self, obj): html = obj.get_photo_html() return mark_safe(html) @@ -73,6 +81,5 @@ admin.site.unregister(Group) # Снятие регистрации станда admin.site.register(User, CustomUserAdmin) # Регистрация настроенного класса администратора пользователей admin.site.register(Group, CustomGroupAdmin) # Регистрация настроенного класса администратора групп -admin.site.register(Orders, OrdersAdmin) - +admin.site.register(Orders, OrdersAdmin) diff --git a/adminpanelapp/models.py b/adminpanelapp/models.py index 060fb63..86409a1 100644 --- a/adminpanelapp/models.py +++ b/adminpanelapp/models.py @@ -1,11 +1,26 @@ -import time from urllib.parse import quote - import requests from django.db import models - from bot_sys.config import GetTelegramBotApiToken + +class Users(models.Model): + user_id = models.CharField(max_length=100, primary_key=True) + userName = models.CharField(max_length=100, verbose_name='Имя пользователя') + userFirstName = models.CharField(max_length=100, verbose_name='Имя') + userLastName = models.CharField(max_length=100, verbose_name='Фамилия') + userIsBot = models.BooleanField(verbose_name='Является ботом') + userLanguageCode = models.CharField(max_length=100, verbose_name='Код языка') + userPhoto = models.ImageField(verbose_name='Фото пользователя') + userAccess = models.CharField(max_length=100, verbose_name='Доступ') + createDateTime = models.DateTimeField(auto_now_add=True, verbose_name='Дата и время создания') + + class Meta: + verbose_name_plural = 'Заказы' + managed = False + db_table = 'users' + + class Orders(models.Model): orderID = models.AutoField(primary_key=True, verbose_name='id заказа') userID = models.CharField(max_length=100, verbose_name='id пользователя в tg', null=True) @@ -17,6 +32,7 @@ class Orders(models.Model): orderAccess = models.CharField(max_length=100, verbose_name='доступ', blank=True, null=True) orderCreateDateTime = models.DateTimeField(auto_now_add=True, null=True, verbose_name='дата и время создания') orderStatus = models.CharField(max_length=100, verbose_name='статус заказа', blank=True, null=True) + catID = models.CharField(max_length=100, verbose_name='категория', blank=True, null=True) def get_photo_html(self, width=100, height=100, large_width=400, large_height=400): file_id = self.orderPhoto @@ -139,4 +155,6 @@ class Orders(models.Model): verbose_name_plural = 'Заказы' managed = False - db_table = 'orders' \ No newline at end of file + db_table = 'orders' + +