Spaces:
Running
Running
Commit Β·
b137359
1
Parent(s): 21e8ee7
customer info added
Browse files- api/camera.py +17 -4
- api/view_image.py +1 -1
api/camera.py
CHANGED
|
@@ -28,6 +28,8 @@ class CameraData(BaseModel):
|
|
| 28 |
user_id: str = Field(..., min_length=1)
|
| 29 |
camera_name: str = Field(..., min_length=1)
|
| 30 |
camera_loc: Optional[List[float]] = None
|
|
|
|
|
|
|
| 31 |
|
| 32 |
@validator("camera_loc")
|
| 33 |
def validate_loc(cls, loc):
|
|
@@ -95,11 +97,22 @@ def add_camera(data: CameraData):
|
|
| 95 |
raise HTTPException(status_code=400, detail="Only 2 cameras allowed")
|
| 96 |
for cam in cameras:
|
| 97 |
if cam["camera_name"].lower() == data.camera_name.lower():
|
| 98 |
-
raise HTTPException(status_code=400, detail="Camera already exists")
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
save_cameras(data.user_id, cameras)
|
| 101 |
-
|
| 102 |
-
|
| 103 |
|
| 104 |
# ---------- EDIT CAMERA ----------
|
| 105 |
@router.put("/edit_camera")
|
|
|
|
| 28 |
user_id: str = Field(..., min_length=1)
|
| 29 |
camera_name: str = Field(..., min_length=1)
|
| 30 |
camera_loc: Optional[List[float]] = None
|
| 31 |
+
customer_email: Optional[str] = None
|
| 32 |
+
customer_name: Optional[str] = None
|
| 33 |
|
| 34 |
@validator("camera_loc")
|
| 35 |
def validate_loc(cls, loc):
|
|
|
|
| 97 |
raise HTTPException(status_code=400, detail="Only 2 cameras allowed")
|
| 98 |
for cam in cameras:
|
| 99 |
if cam["camera_name"].lower() == data.camera_name.lower():
|
| 100 |
+
raise HTTPException(status_code=400, detail="Camera already exists")
|
| 101 |
+
camera_obj = {
|
| 102 |
+
"camera_name": data.camera_name,
|
| 103 |
+
"camera_loc": data.camera_loc
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
# Add customer info if provided
|
| 107 |
+
if data.customer_email:
|
| 108 |
+
camera_obj["customer_email"] = data.customer_email
|
| 109 |
+
if data.customer_name:
|
| 110 |
+
camera_obj["customer_name"] = data.customer_name
|
| 111 |
+
|
| 112 |
+
cameras.append(camera_obj)
|
| 113 |
save_cameras(data.user_id, cameras)
|
| 114 |
+
|
| 115 |
+
return {"success": True, "camera": data.camera_name, "saved_data": camera_obj}
|
| 116 |
|
| 117 |
# ---------- EDIT CAMERA ----------
|
| 118 |
@router.put("/edit_camera")
|
api/view_image.py
CHANGED
|
@@ -47,7 +47,7 @@ def view_images(
|
|
| 47 |
existing_filenames = {item.path.split("/")[-1] for item in raw_files}
|
| 48 |
|
| 49 |
# ββ validate filter label βββββββββββββββββββββββββββββββββββββ
|
| 50 |
-
valid_filters =
|
| 51 |
filter_lower = filter_label.lower() if filter_label else None
|
| 52 |
if filter_lower and filter_lower not in valid_filters:
|
| 53 |
raise HTTPException(
|
|
|
|
| 47 |
existing_filenames = {item.path.split("/")[-1] for item in raw_files}
|
| 48 |
|
| 49 |
# ββ validate filter label βββββββββββββββββββββββββββββββββββββ
|
| 50 |
+
valid_filters ={"doe", "mule bucks", "white tail bucks"}
|
| 51 |
filter_lower = filter_label.lower() if filter_label else None
|
| 52 |
if filter_lower and filter_lower not in valid_filters:
|
| 53 |
raise HTTPException(
|