Skip to content

Commit

Permalink
Updated Saved Search unit tests, test_create_saved_search_by_user in …
Browse files Browse the repository at this point in the history
…passing state; Updated endpoint to expect JSON request to create a saved search;
  • Loading branch information
chrtorres committed Nov 15, 2024
1 parent 0dfc4d8 commit de3157b
Show file tree
Hide file tree
Showing 4 changed files with 329 additions and 284 deletions.
10 changes: 6 additions & 4 deletions backend/src/xfd_django/xfd_api/api_methods/saved_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def create_saved_search(request):
filters=[
{
"type": "any",
"field": request.get("field", "organization.regionId"),
"values": [request.get("regionId")],
"field": request.get("field", ""),
"values": [request.get("values", "")],
}
],
createdById=request.get("createdById"),
Expand Down Expand Up @@ -70,9 +70,11 @@ def create_saved_search(request):
raise HTTPException(status_code=404, detail=str(e))


def list_saved_searches():
def list_saved_searches(user):
"""List all saved searches."""

if user.userType == "globalView":
# raise HTTPException(status_code=403, detail="Global View users cannot access saved searches.")
return []
try:
all_saved_searches = SavedSearch.objects.all()
saved_search_list = []
Expand Down
10 changes: 10 additions & 0 deletions backend/src/xfd_django/xfd_api/schema_models/saved_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class SavedSearchFilters(BaseModel):
values: List[Any]


class SavedSearchCreate(BaseModel):
name: str
searchTerm: str
sortDirection: str
sortField: str
count: int
filters: List[SavedSearchFilters]
searchPath: str


class SavedSearch(BaseModel):
"""SavedSearch schema."""

Expand Down
Loading

0 comments on commit de3157b

Please sign in to comment.