Skip to content

Commit

Permalink
added initial station info test and not requiere sensor data in Creat…
Browse files Browse the repository at this point in the history
…eStationDataAPIView endpoint
  • Loading branch information
Nik Sauer committed Jan 28, 2025
1 parent 1f2bc0c commit a072dec
Show file tree
Hide file tree
Showing 9 changed files with 1,535 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class CreateStationDataAPIView(APIView):
def post(self, request, *args, **kwargs):
# Parse the incoming JSON data
try:
station_data = request.data.get('station')
sensors_data = request.data.get('sensors')
station_data = request.data.get('station', None)
sensors_data = request.data.get('sensors', None)

if not station_data or not sensors_data:
raise ValidationError("Both 'station' and 'sensors' are required.")
Expand All @@ -165,6 +165,9 @@ def post(self, request, *args, **kwargs):
# Record the time when the request was received
time_received = datetime.datetime.now(datetime.timezone.utc)

if sensor_data:
return JsonResponse({"status": "success, but no sensor data found"}, status=200)

try:
with transaction.atomic():
# Iterate through all sensors
Expand Down
3 changes: 3 additions & 0 deletions app/staticfiles/debug_toolbar/css/print.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#djDebug {
display: none !important;
}
Loading

0 comments on commit a072dec

Please sign in to comment.