diff --git a/handles/admin.py b/handles/admin.py index 1a86567ee..7befa157f 100644 --- a/handles/admin.py +++ b/handles/admin.py @@ -1,17 +1,21 @@ from django.contrib import admin from app_users.admin import AppUserAdmin +from workspaces.admin import WorkspaceAdmin from .models import Handle @admin.register(Handle) class HandleAdmin(admin.ModelAdmin): - search_fields = ["name", "redirect_url"] + [ - f"user__{field}" for field in AppUserAdmin.search_fields - ] - readonly_fields = ["user", "created_at", "updated_at"] + search_fields = ( + ["name", "redirect_url"] + + [f"user__{field}" for field in AppUserAdmin.search_fields] + + [f"workspace__{field}" for field in WorkspaceAdmin.search_fields] + ) + readonly_fields = ["user", "workspace", "created_at", "updated_at"] list_filter = [ ("user", admin.EmptyFieldListFilter), + ("workspace", admin.EmptyFieldListFilter), ("redirect_url", admin.EmptyFieldListFilter), ] diff --git a/workspaces/admin.py b/workspaces/admin.py index 85a3ce3a6..c697641ae 100644 --- a/workspaces/admin.py +++ b/workspaces/admin.py @@ -54,6 +54,7 @@ class WorkspaceAdmin(SafeDeleteAdmin): "display_name", "is_personal", "created_by", + "handle", "is_paying", "balance", "subscription", @@ -73,6 +74,7 @@ class WorkspaceAdmin(SafeDeleteAdmin): "name", "description", "domain_name", + "handle", "created_by", "is_personal", ("is_paying", "stripe_customer_id"), @@ -81,7 +83,7 @@ class WorkspaceAdmin(SafeDeleteAdmin): ("created_at", "updated_at"), "open_in_stripe", ] - search_fields = ["name", "created_by__display_name", "domain_name"] + search_fields = ["name", "created_by__display_name", "domain_name", "handle__name"] readonly_fields = [ "is_personal", "created_at", @@ -93,7 +95,7 @@ class WorkspaceAdmin(SafeDeleteAdmin): ] inlines = [WorkspaceMembershipInline, WorkspaceInviteInline] ordering = ["-created_at"] - autocomplete_fields = ["created_by"] + autocomplete_fields = ["created_by", "handle"] def get_form(self, request, obj=None, change=False, **kwargs): self.obj = obj