summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activities/admin.py29
-rw-r--r--core/admin.py25
-rw-r--r--stator/admin.py1
-rw-r--r--users/admin.py21
4 files changed, 75 insertions, 1 deletions
diff --git a/activities/admin.py b/activities/admin.py
index fe7b52f..edc7365 100644
--- a/activities/admin.py
+++ b/activities/admin.py
@@ -1,5 +1,6 @@
from asgiref.sync import async_to_sync
from django.contrib import admin
+from django.utils.translation import gettext_lazy as _
from activities.models import (
FanOut,
@@ -11,9 +12,33 @@ from activities.models import (
)
+class IdentityLocalFilter(admin.SimpleListFilter):
+ title = _("Local Identity")
+ parameter_name = "islocal"
+
+ identity_field_name = "identity"
+
+ def lookups(self, request, model_admin):
+ return (
+ ("1", _("Yes")),
+ ("0", _("No")),
+ )
+
+ def queryset(self, request, queryset):
+ match self.value():
+ case "1":
+ return queryset.filter(**{f"{self.identity_field_name}__local": True})
+ case "0":
+ return queryset.filter(**{f"{self.identity_field_name}__local": False})
+ case _:
+ return queryset
+
+
@admin.register(Hashtag)
class HashtagAdmin(admin.ModelAdmin):
list_display = ["hashtag", "name_override", "state", "stats_updated", "created"]
+ list_filter = ("public", "state", "stats_updated")
+ search_fields = ["hashtag", "aliases"]
readonly_fields = ["created", "updated", "stats_updated"]
@@ -38,6 +63,7 @@ class PostAttachmentInline(admin.StackedInline):
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
list_display = ["id", "state", "author", "created"]
+ list_filter = ("local", "visibility", "state", "created")
raw_id_fields = ["to", "mentions", "author"]
actions = ["force_fetch", "reparse_hashtags"]
search_fields = ["content"]
@@ -70,6 +96,7 @@ class PostAdmin(admin.ModelAdmin):
@admin.register(TimelineEvent)
class TimelineEventAdmin(admin.ModelAdmin):
list_display = ["id", "identity", "created", "type"]
+ list_filter = (IdentityLocalFilter, "type")
readonly_fields = ["created"]
raw_id_fields = [
"identity",
@@ -85,6 +112,7 @@ class TimelineEventAdmin(admin.ModelAdmin):
@admin.register(FanOut)
class FanOutAdmin(admin.ModelAdmin):
list_display = ["id", "state", "state_attempted", "type", "identity"]
+ list_filter = (IdentityLocalFilter, "type", "state", "state_attempted")
raw_id_fields = ["identity", "subject_post", "subject_post_interaction"]
readonly_fields = ["created", "updated"]
actions = ["force_execution"]
@@ -101,6 +129,7 @@ class FanOutAdmin(admin.ModelAdmin):
@admin.register(PostInteraction)
class PostInteractionAdmin(admin.ModelAdmin):
list_display = ["id", "state", "state_attempted", "type", "identity", "post"]
+ list_filter = (IdentityLocalFilter, "type", "state")
raw_id_fields = ["identity", "post"]
def has_add_permission(self, request, obj=None):
diff --git a/core/admin.py b/core/admin.py
index e4a6ad0..a319816 100644
--- a/core/admin.py
+++ b/core/admin.py
@@ -1,8 +1,33 @@
from django.contrib import admin
+from django.utils.translation import gettext_lazy as _
from core.models import Config
+class ConfigOptionsTypeFilter(admin.SimpleListFilter):
+ title = _("config options type")
+ parameter_name = "type"
+
+ def lookups(self, request, model_admin):
+ return (
+ ("system", _("System")),
+ ("identity", _("Identity")),
+ ("user", _("User")),
+ )
+
+ def queryset(self, request, queryset):
+ match self.value():
+ case "system":
+ return queryset.filter(user__isnull=True, identity__isnull=True)
+ case "identity":
+ return queryset.exclude(identity__isnull=True)
+ case "user":
+ return queryset.exclude(user__isnull=True)
+ case _:
+ return queryset
+
+
@admin.register(Config)
class ConfigAdmin(admin.ModelAdmin):
list_display = ["id", "key", "user", "identity"]
+ list_filter = (ConfigOptionsTypeFilter,)
diff --git a/stator/admin.py b/stator/admin.py
index 7d2b0aa..2d001ea 100644
--- a/stator/admin.py
+++ b/stator/admin.py
@@ -13,6 +13,7 @@ class DomainAdmin(admin.ModelAdmin):
"state",
"error",
]
+ list_filter = ["model_label", "date"]
ordering = ["-date"]
def has_add_permission(self, request, obj=None):
diff --git a/users/admin.py b/users/admin.py
index d498343..0b502d5 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -1,5 +1,7 @@
from django.contrib import admin
+from django.utils.translation import gettext_lazy as _
+from activities.admin import IdentityLocalFilter
from users.models import (
Domain,
Follow,
@@ -15,12 +17,15 @@ from users.models import (
@admin.register(Domain)
class DomainAdmin(admin.ModelAdmin):
list_display = ["domain", "service_domain", "local", "blocked", "public"]
+ list_filter = ("local", "blocked")
+ search_fields = ("domain", "service_domain")
@admin.register(User)
class UserAdmin(admin.ModelAdmin):
list_display = ["email", "created", "last_seen", "admin", "moderator", "banned"]
search_fields = ["email"]
+ list_filter = ("admin", "moderator", "banned")
@admin.register(UserEvent)
@@ -32,7 +37,7 @@ class UserEventAdmin(admin.ModelAdmin):
@admin.register(Identity)
class IdentityAdmin(admin.ModelAdmin):
list_display = ["id", "handle", "actor_uri", "state", "local"]
- list_filter = ["local"]
+ list_filter = ("local", "state", "discoverable")
raw_id_fields = ["users"]
actions = ["force_update"]
readonly_fields = ["actor_json"]
@@ -51,9 +56,22 @@ class IdentityAdmin(admin.ModelAdmin):
return False
+class LocalSourceFilter(IdentityLocalFilter):
+ title = _("Local Source Identity")
+ parameter_name = "srclocal"
+ identity_field_name = "source"
+
+
+class LocalTargetFilter(IdentityLocalFilter):
+ title = _("Local Target Identity")
+ parameter_name = "tgtlocal"
+ identity_field_name = "target"
+
+
@admin.register(Follow)
class FollowAdmin(admin.ModelAdmin):
list_display = ["id", "source", "target", "state"]
+ list_filter = [LocalSourceFilter, LocalTargetFilter, "state"]
raw_id_fields = ["source", "target"]
def has_add_permission(self, request, obj=None):
@@ -72,6 +90,7 @@ class PasswordResetAdmin(admin.ModelAdmin):
@admin.register(InboxMessage)
class InboxMessageAdmin(admin.ModelAdmin):
list_display = ["id", "state", "state_changed", "message_type", "message_actor"]
+ list_filter = ("state",)
search_fields = ["message"]
actions = ["reset_state"]
readonly_fields = ["state_changed"]