From 3ea0c1a077865f58ad764de06f510cfff55e5dbb Mon Sep 17 00:00:00 2001 From: nmaytan Date: Thu, 22 Aug 2024 17:13:46 -0400 Subject: [PATCH] Enforce inst/det name uniqueness --- src/nsls2api/services/beamline_service.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nsls2api/services/beamline_service.py b/src/nsls2api/services/beamline_service.py index d0322156..89d4db67 100644 --- a/src/nsls2api/services/beamline_service.py +++ b/src/nsls2api/services/beamline_service.py @@ -120,10 +120,18 @@ async def add_detector( manufacturer=manufacturer, ) + current_detector_names = ( + detector.name for detector in beamlines.detectors + ) current_directory_names = ( detector.directory_name for detector in beamline.detectors ) - if directory_name in current_directory_names: + if detector_name in current_detector_names: + logger.info( + f"Detector with name {detector_name} already exists in beamline {beamline_name}" + ) + return None: + elif directory_name in current_directory_names: logger.info( f"Detector with directory name {directory_name} already exists in beamline {beamline_name}" )