summaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-05 19:54:47 -0700
committerAndrew Godwin2022-12-05 19:54:47 -0700
commite2d28a4be08ccc629def8c85327b657b0bf36f90 (patch)
tree4929ed303b0545fc5b5848f23dee74dbbbcad1f8 /users
parentf22869693a04080c3953a904ffa99e9b317d1736 (diff)
downloadtakahe-e2d28a4be08ccc629def8c85327b657b0bf36f90.tar.gz
takahe-e2d28a4be08ccc629def8c85327b657b0bf36f90.tar.bz2
takahe-e2d28a4be08ccc629def8c85327b657b0bf36f90.zip
Add pagination and search to federation page
Diffstat (limited to 'users')
-rw-r--r--users/views/admin/federation.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/users/views/admin/federation.py b/users/views/admin/federation.py
index 4d6b179..0611b9e 100644
--- a/users/views/admin/federation.py
+++ b/users/views/admin/federation.py
@@ -2,24 +2,35 @@ from django import forms
from django.db import models
from django.shortcuts import get_object_or_404, redirect
from django.utils.decorators import method_decorator
-from django.views.generic import FormView, TemplateView
+from django.views.generic import FormView, ListView
from users.decorators import admin_required
from users.models import Domain
@method_decorator(admin_required, name="dispatch")
-class FederationRoot(TemplateView):
+class FederationRoot(ListView):
template_name = "admin/federation.html"
+ paginate_by = 50
- def get_context_data(self):
- return {
- "domains": Domain.objects.filter(local=False)
- .annotate(num_users=models.Count("identities"))
- .order_by("domain"),
+ def get(self, request, *args, **kwargs):
+ self.query = request.GET.get("query")
+ self.extra_context = {
"section": "federation",
+ "query": self.query or "",
}
+ return super().get(request, *args, **kwargs)
+
+ def get_queryset(self):
+ domains = (
+ Domain.objects.filter(local=False)
+ .annotate(num_users=models.Count("identities"))
+ .order_by("domain")
+ )
+ if self.query:
+ domains = domains.filter(domain__icontains=self.query)
+ return domains
@method_decorator(admin_required, name="dispatch")