|
|
|
@ -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) |
|
|
|
|