From 3a22da3dc3c74399e41d9488420de69526c17eed Mon Sep 17 00:00:00 2001 From: yuwol Date: Tue, 23 Jan 2024 17:42:30 +0000 Subject: [PATCH] fix(permission): fix admin page for `UserGroup` --- apps/user/admin.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/apps/user/admin.py b/apps/user/admin.py index 5e6a9ebb..0ea863cd 100644 --- a/apps/user/admin.py +++ b/apps/user/admin.py @@ -38,25 +38,34 @@ class ManualUserAdmin(MetaDataModelAdmin): @admin.register(UserGroup) -class UserGroupAdmin(MetaDataModelAdmin): +class UserGroupAdmin(admin.ModelAdmin): list_display = ( - "user_id", - "group_id", + "user", + "nickname", + "email", + "group", ) + list_filter = ("group",) search_fields = ( - "user_id", - "group_id", + "user__id", + "user__profile__nickname", + "user__email", ) + @admin.display(description="닉네임") + def nickname(self, obj: UserGroup): + return obj.user.profile.nickname + + @admin.display(description="이메일") + def email(self, obj: UserGroup): + return obj.user.email + @admin.register(Group) -class GroupAdmin(MetaDataModelAdmin): +class GroupAdmin(admin.ModelAdmin): list_display = ( - "group_id", "name", + "description", "is_official", ) - search_fields = ( - "id", - "name", - ) + search_fields = ("name",)