Skip to content

Commit

Permalink
Admin speedups, mastodon-compatible settings redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwatson committed May 1, 2024
1 parent ee2e304 commit ff0c960
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
17 changes: 10 additions & 7 deletions activities/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ class EmojiAdmin(admin.ModelAdmin):
)
list_filter = ("local", "public", "state")
search_fields = ("shortcode",)

readonly_fields = ["preview", "created", "updated", "to_ap_tag"]

autocomplete_fields = ["domain"]
actions = ["force_execution", "approve_emoji", "reject_emoji", "copy_to_local"]

def delete_queryset(self, request, queryset):
Expand Down Expand Up @@ -122,6 +121,7 @@ class PostAttachmentAdmin(admin.ModelAdmin):
list_filter = ["state", "mimetype"]
search_fields = ["name", "remote_url", "search_handle", "search_service_handle"]
raw_id_fields = ["post"]
autocomplete_fields = ["author"]

actions = ["guess_mimetypes"]

Expand Down Expand Up @@ -194,13 +194,12 @@ def has_add_permission(self, request, obj=None):

@admin.register(TimelineEvent)
class TimelineEventAdmin(admin.ModelAdmin):
list_display = ["id", "identity", "published", "type"]
list_display = ["id", "identity", "type", "published"]
list_filter = (IdentityLocalFilter, "type")
readonly_fields = ["created"]
autocomplete_fields = ["identity"]
autocomplete_fields = ["identity", "subject_identity"]
raw_id_fields = [
"subject_post",
"subject_identity",
"subject_post_interaction",
]

Expand All @@ -212,8 +211,12 @@ def has_add_permission(self, request, obj=None):
class FanOutAdmin(admin.ModelAdmin):
list_display = ["id", "state", "created", "state_next_attempt", "type", "identity"]
list_filter = (IdentityLocalFilter, "type", "state")
raw_id_fields = ["subject_post", "subject_post_interaction"]
autocomplete_fields = ["identity"]
raw_id_fields = [
"subject_post",
"subject_post_interaction",
"subject_hashtag",
]
autocomplete_fields = ["identity", "subject_identity"]
readonly_fields = ["created", "updated", "state_changed"]
actions = ["force_execution"]
search_fields = ["identity__username"]
Expand Down
2 changes: 2 additions & 0 deletions api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
@admin.register(Application)
class ApplicationAdmin(admin.ModelAdmin):
list_display = ["id", "name", "website", "created"]
search_fields = ["name", "website"]


@admin.register(Token)
class TokenAdmin(admin.ModelAdmin):
list_display = ["id", "user", "identity", "application", "created"]
autocomplete_fields = ["user", "identity", "application"]
6 changes: 5 additions & 1 deletion core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def lookups(self, request, model_admin):
("system", _("System")),
("identity", _("Identity")),
("user", _("User")),
("domain", _("Domain")),
)

def queryset(self, request, queryset):
Expand All @@ -23,11 +24,14 @@ def queryset(self, request, queryset):
return queryset.exclude(identity__isnull=True)
case "user":
return queryset.exclude(user__isnull=True)
case "domain":
return queryset.exclude(domain__isnull=True)
case _:
return queryset


@admin.register(Config)
class ConfigAdmin(admin.ModelAdmin):
list_display = ["id", "key", "user", "identity"]
list_display = ["id", "key", "user", "identity", "domain"]
list_filter = (ConfigOptionsTypeFilter,)
autocomplete_fields = ["user", "identity", "domain"]
6 changes: 6 additions & 0 deletions takahe/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.conf import settings as djsettings
from django.contrib import admin as djadmin
from django.urls import include, path, re_path
from django.views.generic.base import RedirectView

from activities.views import compose, debug, posts, timelines
from api.views import oauth
Expand All @@ -20,6 +21,11 @@
settings.SettingsRoot.as_view(),
name="settings",
),
# Some clients assume this exists, redirect to root settings page.
path(
"settings/profile/",
RedirectView.as_view(pattern_name="settings"),
),
path(
"settings/security/",
settings.SecurityPage.as_view(),
Expand Down
18 changes: 15 additions & 3 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class UserAdmin(admin.ModelAdmin):

@admin.register(UserEvent)
class UserEventAdmin(admin.ModelAdmin):
list_display = ["user", "type", "date"]
autocomplete_fields = ["user"]

def has_add_permission(self, request, obj=None):
return False

Expand All @@ -111,7 +114,7 @@ def has_add_permission(self, request, obj=None):
class IdentityAdmin(admin.ModelAdmin):
list_display = ["id", "handle", "actor_uri", "state", "local"]
list_filter = ("local", "state", "discoverable")
autocomplete_fields = ["users"]
autocomplete_fields = ["users", "domain"]
actions = ["force_update"]
readonly_fields = ["handle", "actor_json"]
search_fields = ["search_handle", "search_service_handle", "name", "id"]
Expand Down Expand Up @@ -217,17 +220,25 @@ class InviteAdmin(admin.ModelAdmin):
@admin.register(List)
class ListAdmin(admin.ModelAdmin):
list_display = ["id", "identity", "title", "replies_policy", "exclusive"]
autocomplete_fields = ["members"]
autocomplete_fields = ["identity", "members"]


@admin.register(Marker)
class MarkerAdmin(admin.ModelAdmin):
list_display = ["id", "identity", "timeline", "last_read_id", "updated_at"]
autocomplete_fields = ["identity"]


@admin.register(Report)
class ReportAdmin(admin.ModelAdmin):
list_display = ["id", "created", "resolved", "type", "subject_identity"]
raw_id_fields = ["subject_post"]
autocomplete_fields = [
"subject_identity",
"source_identity",
"source_domain",
"moderator",
]


@admin.register(Announcement)
Expand All @@ -239,4 +250,5 @@ class AnnouncementAdmin(admin.ModelAdmin):
@admin.register(Bookmark)
class BookmarkAdmin(admin.ModelAdmin):
list_display = ["id", "identity", "post", "created"]
raw_id_fields = ["identity", "post"]
autocomplete_fields = ["identity"]
raw_id_fields = ["post"]

0 comments on commit ff0c960

Please sign in to comment.