1
0
Fork 0

Move deleted users to a separate tab

Since there's nothing to be done with them, they get their own tab.
This commit is contained in:
Mouse Reeve 2022-07-08 09:19:48 -07:00
parent 5bb001e15f
commit be86fef42d
3 changed files with 16 additions and 8 deletions

View file

@ -22,21 +22,25 @@ class UserAdminList(View):
def get(self, request, status="local"):
"""list of users"""
filters = {}
exclusions = {}
if server := request.GET.get("server"):
server = models.FederatedServer.objects.filter(server_name=server).first()
filters["federated_server"] = server
filters["federated_server__isnull"] = False
if username := request.GET.get("username"):
filters["username__icontains"] = username
scope = request.GET.get("scope")
if scope and scope == "local":
filters["local"] = True
if email := request.GET.get("email"):
filters["email__endswith"] = email
filters["local"] = status == "local"
filters["local"] = status in ["local", "deleted"]
if status == "deleted":
filters["deactivation_reason__icontains"] = "deletion"
else:
exclusions["deactivation_reason__icontains"] = "deletion"
users = models.User.objects.filter(**filters)
users = models.User.objects.filter(**filters).exclude(**exclusions)
sort = request.GET.get("sort", "-created_date")
sort_fields = [