Skip to content

Commit 6c59363

Browse files
committed
Fixy little fix
1 parent 68519d2 commit 6c59363

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/api/api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ async def get_camera(camera_id: int):
223223
@self.app.put("/cameras/{camera_id}")
224224
async def update_camera(camera_id: int, updated_fields: Request):
225225
try:
226+
if not isinstance(updated_fields, dict):
227+
raise HTTPException(
228+
status_code=400,
229+
detail="Request body must be a JSON dict"
230+
)
231+
226232
updated_fields = await updated_fields.json()
227233
camera = self.db_manager.update_camera(camera_id, updated_fields)
228234

@@ -245,6 +251,12 @@ async def update_camera(camera_id: int, updated_fields: Request):
245251
@self.app.put("/zones/{zone_id}")
246252
async def update_zone(zone_id: int, updated_fields: Request):
247253
try:
254+
if not isinstance(updated_fields, dict):
255+
raise HTTPException(
256+
status_code=400,
257+
detail="Request body must be a JSON dict"
258+
)
259+
248260
updated_fields = await updated_fields.json()
249261
zone = self.db_manager.update_zone(zone_id, updated_fields)
250262

src/db_manager/db_manager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ def update_camera(self, camera_id, updated_fields):
281281
stmt = update(Camera).where(Camera.id == camera_id)
282282

283283
stmt = stmt.values(updated_fields)
284-
print(updated_fields)
285284

286285
session.execute(stmt)
287286

0 commit comments

Comments
 (0)