robosats/chat/admin.py

52 lines
1.2 KiB
Python
Raw Normal View History

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-10-25 18:04:12 +00:00
2022-05-28 13:01:50 +00:00
from chat.models import ChatRoom, Message
2022-10-20 09:56:10 +00:00
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-10-20 09:56:10 +00:00
change_links = ["order", "maker", "taker"]
2022-05-28 13:01:50 +00:00
search_fields = ["id"]
2023-04-27 09:38:16 +00:00
raw_id_fields = (
"order",
"maker",
"taker",
)
2022-05-28 13:01:50 +00:00
2022-10-20 09:56:10 +00:00
2022-05-28 13:01:50 +00:00
@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",
)
2022-10-20 09:56:10 +00:00
change_links = ["chatroom", "order", "sender", "receiver"]
search_fields = ["id", "index"]
ordering = ["-chatroom_id", "-index"]
list_filter = ("chatroom",)
2023-04-27 09:38:16 +00:00
raw_id_fields = (
"order",
"chatroom",
"receiver",
"sender",
)