Swap a decent number of admin fields to autocomplete

This commit is contained in:
Andrew Godwin 2023-01-26 10:01:21 -07:00
parent 75ba7e3160
commit 653ab07fd6
2 changed files with 13 additions and 10 deletions

View file

@ -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

View file

@ -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"]