-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathleaf_test_api.py
More file actions
43 lines (35 loc) · 1.46 KB
/
leaf_test_api.py
File metadata and controls
43 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
# from utils.firebase import get_collection, get_document, update_document
from utils.firebase import get_collection
@api_view(["GET", "POST"])
def lab_results(request, format=None):
"""Get lab results data."""
if request.method == "GET":
limit = request.query_params.get("limit", 1000)
if limit:
limit = int(limit)
order_by = request.query_params.get("order_by", "")
# TODO: Get any filters from dict(request.query_params)
docs = get_collection(
"tests/leaf/lab_results", order_by=order_by, limit=limit, filters=[]
)
return Response(docs, content_type="application/json")
if request.method == "POST":
print("TODO: Create lab results")
return NotImplementedError
@api_view(["GET"])
def mmes(request, format=None):
"""Get licensee (MME) data."""
if request.method == "GET":
limit = request.query_params.get("limit", None)
if limit:
limit = int(limit)
order_by = request.query_params.get("order_by", "")
# TODO: Get any filters from dict(request.query_params)
# e.g. {"key": "name", "operation": "==", "value": "xyz"}
docs = get_collection(
"tests/leaf/mmes", order_by=order_by, limit=limit, filters=[]
)
return Response(docs, content_type="application/json")