Anton
1 year ago
14 changed files with 8 additions and 129 deletions
@ -1,16 +0,0 @@ |
|||||||
""" |
|
||||||
ASGI config for adminpanel project. |
|
||||||
|
|
||||||
It exposes the ASGI callable as a module-level variable named ``application``. |
|
||||||
|
|
||||||
For more information on this file, see |
|
||||||
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ |
|
||||||
""" |
|
||||||
|
|
||||||
import os |
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application |
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'adminpanel.settings') |
|
||||||
|
|
||||||
application = get_asgi_application() |
|
@ -1,11 +0,0 @@ |
|||||||
from django.contrib import admin |
|
||||||
from django.urls import path, include |
|
||||||
from django.views.generic import RedirectView |
|
||||||
from django.conf import settings |
|
||||||
from django.conf.urls.static import static |
|
||||||
|
|
||||||
urlpatterns = [ |
|
||||||
path('admin/', admin.site.urls), |
|
||||||
path('', include('adminpanelapp.urls')), |
|
||||||
path('', RedirectView.as_view(url='/admin/adminpanelapp/orders'), name='') |
|
||||||
] |
|
@ -1,16 +0,0 @@ |
|||||||
""" |
|
||||||
WSGI config for adminpanel project. |
|
||||||
|
|
||||||
It exposes the WSGI callable as a module-level variable named ``application``. |
|
||||||
|
|
||||||
For more information on this file, see |
|
||||||
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ |
|
||||||
""" |
|
||||||
|
|
||||||
import os |
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application |
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'adminpanel.settings') |
|
||||||
|
|
||||||
application = get_wsgi_application() |
|
@ -1,44 +0,0 @@ |
|||||||
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 django.contrib import admin, messages |
|
||||||
from django.urls import reverse |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OrdersAdmin(admin.ModelAdmin): |
|
||||||
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) |
|
||||||
|
|
||||||
show_photo.short_description = 'Фото' |
|
||||||
|
|
||||||
def show_photopay(self, obj): |
|
||||||
html = obj.get_photopay_html() |
|
||||||
return mark_safe(html) |
|
||||||
|
|
||||||
show_photopay.short_description = 'Чек' |
|
||||||
|
|
||||||
def send_message(orders, request, queryset): |
|
||||||
selected_objects = request.POST.getlist(ACTION_CHECKBOX_NAME) |
|
||||||
if len(selected_objects) != 1: |
|
||||||
messages.error(request, "Выберите только один объект") |
|
||||||
return |
|
||||||
|
|
||||||
selected_user_id = int(selected_objects[0]) |
|
||||||
obj = queryset.get(orderID=selected_user_id) |
|
||||||
user_id = obj.userID |
|
||||||
url = reverse('send_telegram_message', kwargs={'chat_id': user_id}) |
|
||||||
return HttpResponseRedirect(url) |
|
||||||
|
|
||||||
|
|
||||||
send_message.short_description = 'Отправка сообщения' |
|
||||||
|
|
||||||
admin.site.register(Orders, OrdersAdmin) |
|
@ -1,6 +0,0 @@ |
|||||||
from django.apps import AppConfig |
|
||||||
|
|
||||||
|
|
||||||
class AdminpanelappConfig(AppConfig): |
|
||||||
default_auto_field = 'django.db.models.BigAutoField' |
|
||||||
name = 'adminpanelapp' |
|
@ -1,3 +0,0 @@ |
|||||||
from django.test import TestCase |
|
||||||
|
|
||||||
# Create your tests here. |
|
@ -1,10 +0,0 @@ |
|||||||
from django.urls import path, include |
|
||||||
from .views import send_telegram_message |
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [ |
|
||||||
path('send_telegram_message/<int:chat_id>/', send_telegram_message, name='send_telegram_message'), |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
] |
|
@ -1,22 +0,0 @@ |
|||||||
#!/usr/bin/env python |
|
||||||
"""Django's command-line utility for administrative tasks.""" |
|
||||||
import os |
|
||||||
import sys |
|
||||||
|
|
||||||
|
|
||||||
def main(): |
|
||||||
"""Run administrative tasks.""" |
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'adminpanel.settings') |
|
||||||
try: |
|
||||||
from django.core.management import execute_from_command_line |
|
||||||
except ImportError as exc: |
|
||||||
raise ImportError( |
|
||||||
"Couldn't import Django. Are you sure it's installed and " |
|
||||||
"available on your PYTHONPATH environment variable? Did you " |
|
||||||
"forget to activate a virtual environment?" |
|
||||||
) from exc |
|
||||||
execute_from_command_line(sys.argv) |
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__': |
|
||||||
main() |
|
Loading…
Reference in new issue