Skip to content

Commit a4ded25

Browse files
committed
make chain query param for list deets
1 parent 504efcc commit a4ded25

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

api/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
path("v1/donors", DonorsAPI.as_view(), name="donors_api"),
136136
# lists
137137
path("v1/lists", ListsListAPI.as_view(), name="lists_api"),
138-
path("v1/lists/<int:chain>/<int:list_id>", ListDetailAPI.as_view(), name="lists_api_by_id"),
138+
path("v1/lists/<int:list_id>", ListDetailAPI.as_view(), name="lists_api_by_id"),
139139
path(
140140
"v1/lists/<int:list_id>/registrations",
141141
ListRegistrationsAPI.as_view(),

lists/api.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ class ListDetailAPI(APIView):
116116
@extend_schema(
117117
parameters=[
118118
OpenApiParameter("list_id", int, OpenApiParameter.PATH),
119-
OpenApiParameter("chain", int, OpenApiParameter.PATH),
119+
OpenApiParameter(
120+
"chain",
121+
str,
122+
OpenApiParameter.QUERY,
123+
description="Filter lists by chain id",
124+
),
120125
],
121126
responses={
122127
200: OpenApiResponse(
@@ -139,12 +144,12 @@ class ListDetailAPI(APIView):
139144
@method_decorator(cache_page(60 * 5))
140145
def get(self, request: Request, *args, **kwargs):
141146
list_id = kwargs.get("list_id")
142-
chain = kwargs.get("chain")
147+
chain = request.query_params.get("chain")
143148
try:
144-
list_obj = List.objects.select_related("owner").prefetch_related("admins").get(on_chain_id=list_id, chain=chain)
149+
list_obj = List.objects.select_related("owner").prefetch_related("admins").get(on_chain_id=list_id, chain=1 if not chain else chain)
145150
except List.DoesNotExist:
146151
return Response(
147-
{"message": f"List with onchain ID {list_id} not found on chain {chain}."}, status=404
152+
{"message": f"List with onchain ID {list_id} not found."}, status=404
148153
)
149154
serializer = ListSerializer(list_obj)
150155
return Response(serializer.data)

0 commit comments

Comments
 (0)