Admin tweaks

This commit is contained in:
Andrew Godwin 2022-11-27 17:16:09 -07:00
parent 3b079526a2
commit 0221ea261f
3 changed files with 25 additions and 4 deletions

View File

@ -50,6 +50,9 @@ class TimelineEventAdmin(admin.ModelAdmin):
"subject_post_interaction", "subject_post_interaction",
] ]
def has_add_permission(self, request, obj=None):
return False
@admin.register(FanOut) @admin.register(FanOut)
class FanOutAdmin(admin.ModelAdmin): class FanOutAdmin(admin.ModelAdmin):
@ -63,8 +66,14 @@ class FanOutAdmin(admin.ModelAdmin):
for instance in queryset: for instance in queryset:
instance.transition_perform("new") instance.transition_perform("new")
def has_add_permission(self, request, obj=None):
return False
@admin.register(PostInteraction) @admin.register(PostInteraction)
class PostInteractionAdmin(admin.ModelAdmin): class PostInteractionAdmin(admin.ModelAdmin):
list_display = ["id", "state", "state_attempted", "type", "identity", "post"] list_display = ["id", "state", "state_attempted", "type", "identity", "post"]
raw_id_fields = ["identity", "post"] raw_id_fields = ["identity", "post"]
def has_add_permission(self, request, obj=None):
return False

View File

@ -14,3 +14,6 @@ class DomainAdmin(admin.ModelAdmin):
"error", "error",
] ]
ordering = ["-date"] ordering = ["-date"]
def has_add_permission(self, request, obj=None):
return False

View File

@ -20,11 +20,13 @@ class DomainAdmin(admin.ModelAdmin):
@admin.register(User) @admin.register(User)
class UserAdmin(admin.ModelAdmin): class UserAdmin(admin.ModelAdmin):
list_display = ["email", "created", "last_seen", "admin", "moderator", "banned"] list_display = ["email", "created", "last_seen", "admin", "moderator", "banned"]
search_fields = ["email"]
@admin.register(UserEvent) @admin.register(UserEvent)
class UserEventAdmin(admin.ModelAdmin): class UserEventAdmin(admin.ModelAdmin):
pass def has_add_permission(self, request, obj=None):
return False
@admin.register(Identity) @admin.register(Identity)
@ -34,6 +36,7 @@ class IdentityAdmin(admin.ModelAdmin):
raw_id_fields = ["users"] raw_id_fields = ["users"]
actions = ["force_update"] actions = ["force_update"]
readonly_fields = ["actor_json"] readonly_fields = ["actor_json"]
search_fields = ["username", "name"]
@admin.action(description="Force Update") @admin.action(description="Force Update")
def force_update(self, request, queryset): def force_update(self, request, queryset):
@ -45,9 +48,6 @@ class IdentityAdmin(admin.ModelAdmin):
return instance.to_ap() return instance.to_ap()
def has_add_permission(self, request, obj=None): def has_add_permission(self, request, obj=None):
"""
Disables admin creation of identities as it will skip steps
"""
return False return False
@ -56,12 +56,18 @@ class FollowAdmin(admin.ModelAdmin):
list_display = ["id", "source", "target", "state"] list_display = ["id", "source", "target", "state"]
raw_id_fields = ["source", "target"] raw_id_fields = ["source", "target"]
def has_add_permission(self, request, obj=None):
return False
@admin.register(PasswordReset) @admin.register(PasswordReset)
class PasswordResetAdmin(admin.ModelAdmin): class PasswordResetAdmin(admin.ModelAdmin):
list_display = ["id", "user", "created"] list_display = ["id", "user", "created"]
raw_id_fields = ["user"] raw_id_fields = ["user"]
def has_add_permission(self, request, obj=None):
return False
@admin.register(InboxMessage) @admin.register(InboxMessage)
class InboxMessageAdmin(admin.ModelAdmin): class InboxMessageAdmin(admin.ModelAdmin):
@ -75,6 +81,9 @@ class InboxMessageAdmin(admin.ModelAdmin):
for instance in queryset: for instance in queryset:
instance.transition_perform("received") instance.transition_perform("received")
def has_add_permission(self, request, obj=None):
return False
@admin.register(Invite) @admin.register(Invite)
class InviteAdmin(admin.ModelAdmin): class InviteAdmin(admin.ModelAdmin):