Skip to content

Commit 34c5a4c

Browse files
committed
Adding an un-filtered geo tree endpoint for contrib.
1 parent 107f822 commit 34c5a4c

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/api/contrib/samples.http

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,9 @@ Accept-Language: en-US,en;q=0.5
100100
}
101101
}
102102

103+
###
104+
105+
# @name location_tree
106+
GET {{CurrentHost}}/contrib/location_tree
107+
103108
###

src/api/contrib/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.urls import path
2-
from .views import batch_data_api
2+
from .views import batch_data_api, location_tree
33

44
urlpatterns = [
55
path('data', batch_data_api, name='contrib_data_api'),
6+
path('location_tree', location_tree, name='location_tree'),
67
]

src/api/contrib/views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from django.db.models import Q, Model
1111
from django.apps import apps
1212

13+
from geo.common import GeoTreeFilter
14+
1315
# Type definitions to match the TypeScript interface
1416
NonNullFieldValue = Union[str, int, float, bool]
1517
BaseFieldValue = Optional[NonNullFieldValue]
@@ -125,3 +127,7 @@ def batch_data_api(request):
125127
return JsonResponse({"error": "Invalid JSON"}, status=400)
126128
except Exception as e:
127129
return JsonResponse({"error": str(e)}, status=500)
130+
131+
@csrf_exempt
132+
def location_tree(_):
133+
return JsonResponse(GeoTreeFilter(select_all=True), safe=False)

0 commit comments

Comments
 (0)