2022-01-13 11:07:20 +00:00
|
|
|
from django.contrib import admin
|
2022-03-10 21:35:16 +00:00
|
|
|
from django_admin_relation_links import AdminChangeLinksMixin
|
2022-05-28 13:01:50 +00:00
|
|
|
from chat.models import ChatRoom, Message
|
2022-01-13 11:07:20 +00:00
|
|
|
# Register your models here.
|
2022-03-10 21:35:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(ChatRoom)
|
2022-03-11 14:33:07 +00:00
|
|
|
class ChatRoomAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
|
2022-03-10 21:35:16 +00:00
|
|
|
list_display = (
|
|
|
|
"id",
|
|
|
|
"order_link",
|
|
|
|
"maker_link",
|
|
|
|
"taker_link",
|
|
|
|
"maker_connected",
|
|
|
|
"taker_connected",
|
|
|
|
"maker_connect_date",
|
|
|
|
"taker_connect_date",
|
|
|
|
"room_group_name",
|
|
|
|
)
|
2022-03-11 14:33:07 +00:00
|
|
|
change_links = ["order","maker","taker"]
|
2022-05-28 13:01:50 +00:00
|
|
|
search_fields = ["id"]
|
|
|
|
|
|
|
|
@admin.register(Message)
|
|
|
|
class MessageAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
|
|
|
|
list_display = (
|
|
|
|
"id",
|
|
|
|
"chatroom_link",
|
|
|
|
"order_link",
|
|
|
|
"sender_link",
|
|
|
|
"receiver_link",
|
|
|
|
"created_at",
|
|
|
|
)
|
|
|
|
change_links = ["chatroom","order","sender","receiver"]
|
|
|
|
search_fields = ["id","order"]
|
|
|
|
ordering = ("-index", )
|
|
|
|
list_filter = ("chatroom",)
|