mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-04 00:42:16 +02:00
added status filter to domain json search
This commit is contained in:
parent
2315013ac7
commit
8e50ac82f2
1 changed files with 8 additions and 1 deletions
|
@ -20,11 +20,18 @@ def get_domains_json(request):
|
|||
# Handle sorting
|
||||
sort_by = request.GET.get("sort_by", "id") # Default to 'id'
|
||||
order = request.GET.get("order", "asc") # Default to 'asc'
|
||||
search_term = request.GET.get("search_term")
|
||||
|
||||
# Handle search term
|
||||
search_term = request.GET.get("search_term")
|
||||
if search_term:
|
||||
objects = objects.filter(Q(name__icontains=search_term))
|
||||
|
||||
# Handle state
|
||||
status_param = request.GET.get("status")
|
||||
if status_param:
|
||||
status_list = status_param.split(',')
|
||||
objects = objects.filter(state__in=status_list)
|
||||
|
||||
if sort_by == "state_display":
|
||||
# Fetch the objects and sort them in Python
|
||||
objects = list(objects) # Evaluate queryset to a list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue