Parcourir la source

nutikodu-web: CCM — keeldu pimedast referentsist (summa < 300, v.a must)

ardo il y a 1 semaine
Parent
commit
536d7a6ccc
1 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. 6 0
      dev/nutikodu-web/app.py

+ 6 - 0
dev/nutikodu-web/app.py

@@ -645,6 +645,12 @@ async def varv_ref_set(payload: dict = Body(...)) -> dict:
     for f in VARV_CALIB_FIELDS:
         vals = [float(r[f]) for r in rows if r.get(f) is not None]
         ref[f] = round(sum(vals) / len(vals), 3) if vals else 0.0
+    total = sum(ref.get(b, 0.0) for b in VARV_BANDS)
+    if (tr + tg + tb) >= 10 and total < 300:
+        raise HTTPException(
+            status_code=422,
+            detail="Mõõtmine on liiga tume (värv ei ole ekraanil?). Kuva värv täisheledusel ja oota, kuni mõõtmine on HELE, siis salvesta.",
+        )
     row = {"name": name, "tr": tr, "tg": tg, "tb": tb, **ref}
     resp = requests.post(
         f"{CH_URL}/",