From 653ab07fd6faa980b8351df32795297d0d05a64e Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Thu, 26 Jan 2023 10:01:21 -0700 Subject: [PATCH] Swap a decent number of admin fields to autocomplete --- activities/admin.py | 11 +++++++---- users/admin.py | 12 ++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/activities/admin.py b/activities/admin.py index 3711199..f3444ed 100644 --- a/activities/admin.py +++ b/activities/admin.py @@ -163,7 +163,8 @@ class PostAttachmentInline(admin.StackedInline): class PostAdmin(admin.ModelAdmin): list_display = ["id", "type", "author", "state", "created"] list_filter = ("type", "local", "visibility", "state", "created") - raw_id_fields = ["to", "mentions", "author", "emojis"] + raw_id_fields = ["emojis"] + autocomplete_fields = ["to", "mentions", "author"] actions = ["reparse_hashtags"] search_fields = ["content", "search_handle", "search_service_handle"] inlines = [PostAttachmentInline] @@ -205,8 +206,8 @@ class TimelineEventAdmin(admin.ModelAdmin): list_display = ["id", "identity", "published", "type"] list_filter = (IdentityLocalFilter, "type") readonly_fields = ["created"] + autocomplete_fields = ["identity"] raw_id_fields = [ - "identity", "subject_post", "subject_identity", "subject_post_interaction", @@ -220,7 +221,8 @@ class TimelineEventAdmin(admin.ModelAdmin): class FanOutAdmin(admin.ModelAdmin): list_display = ["id", "state", "created", "state_attempted", "type", "identity"] list_filter = (IdentityLocalFilter, "type", "state", "state_attempted") - raw_id_fields = ["identity", "subject_post", "subject_post_interaction"] + raw_id_fields = ["subject_post", "subject_post_interaction"] + autocomplete_fields = ["identity"] readonly_fields = ["created", "updated", "state_changed"] actions = ["force_execution"] search_fields = ["identity__username"] @@ -238,7 +240,8 @@ class FanOutAdmin(admin.ModelAdmin): class PostInteractionAdmin(admin.ModelAdmin): list_display = ["id", "state", "state_attempted", "type", "identity", "post"] list_filter = (IdentityLocalFilter, "type", "state") - raw_id_fields = ["identity", "post"] + raw_id_fields = ["post"] + autocomplete_fields = ["identity"] def has_add_permission(self, request, obj=None): return False diff --git a/users/admin.py b/users/admin.py index e9ba52a..7494c7a 100644 --- a/users/admin.py +++ b/users/admin.py @@ -33,7 +33,7 @@ class DomainAdmin(admin.ModelAdmin): ] list_filter = ("local", "blocked") search_fields = ("domain", "service_domain") - raw_id_fields = ("users",) + autocomplete_fields = ("users",) actions = [ "force_outdated", "force_updated", @@ -109,7 +109,7 @@ class UserEventAdmin(admin.ModelAdmin): class IdentityAdmin(admin.ModelAdmin): list_display = ["id", "handle", "actor_uri", "state", "local"] list_filter = ("local", "state", "discoverable") - raw_id_fields = ["users"] + autocomplete_fields = ["users"] actions = ["force_update"] readonly_fields = ["handle", "actor_json"] search_fields = ["search_handle", "search_service_handle", "name", "id"] @@ -159,7 +159,7 @@ class LocalTargetFilter(IdentityLocalFilter): class FollowAdmin(admin.ModelAdmin): list_display = ["id", "source", "target", "state"] list_filter = [LocalSourceFilter, LocalTargetFilter, "state"] - raw_id_fields = ["source", "target"] + autocomplete_fields = ["source", "target"] def has_add_permission(self, request, obj=None): return False @@ -169,7 +169,7 @@ class FollowAdmin(admin.ModelAdmin): class BlockAdmin(admin.ModelAdmin): list_display = ["id", "source", "target", "mute", "state"] list_filter = [LocalSourceFilter, LocalTargetFilter, "state"] - raw_id_fields = ["source", "target"] + autocomplete_fields = ["source", "target"] def has_add_permission(self, request, obj=None): return False @@ -178,7 +178,7 @@ class BlockAdmin(admin.ModelAdmin): @admin.register(PasswordReset) class PasswordResetAdmin(admin.ModelAdmin): list_display = ["id", "user", "created"] - raw_id_fields = ["user"] + autocomplete_fields = ["user"] def has_add_permission(self, request, obj=None): return False @@ -220,4 +220,4 @@ class ReportAdmin(admin.ModelAdmin): @admin.register(Announcement) class AnnouncementAdmin(admin.ModelAdmin): list_display = ["id", "published", "start", "end", "text"] - raw_id_fields = ["seen"] + autocomplete_fields = ["seen"]