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",
|
2022-05-28 14:59:32 +00:00
|
|
|
"index",
|
2022-05-28 13:01:50 +00:00
|
|
|
"order_link",
|
|
|
|
"sender_link",
|
|
|
|
"receiver_link",
|
|
|
|
"created_at",
|
|
|
|
)
|
|
|
|
change_links = ["chatroom","order","sender","receiver"]
|
2022-05-28 14:59:32 +00:00
|
|
|
search_fields = ["id","index"]
|
|
|
|
ordering = ["-chatroom_id","-index"]
|
2022-05-28 13:01:50 +00:00
|
|
|
list_filter = ("chatroom",)
|