From bc3927759fbb6a60f4848575ae6e5cd29b68cae2 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 30 Nov 2020 17:10:00 +0000 Subject: [PATCH] Handle missing endpoints --- openflexure_microscope/api/v2/views/captures.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/openflexure_microscope/api/v2/views/captures.py b/openflexure_microscope/api/v2/views/captures.py index 75b8cc51..e3c1fce4 100644 --- a/openflexure_microscope/api/v2/views/captures.py +++ b/openflexure_microscope/api/v2/views/captures.py @@ -79,19 +79,25 @@ class CaptureSchema(ImageSchema): "href": url_for(CaptureView.endpoint, id_=capture_id, _external=True), "mimetype": "application/json", **description_from_view(CaptureView), - }, + } + if CaptureView.endpoint + else {}, "tags": { "href": url_for(CaptureTags.endpoint, id_=capture_id, _external=True), "mimetype": "application/json", **description_from_view(CaptureTags), - }, + } + if CaptureTags.endpoint + else {}, "annotations": { "href": url_for( CaptureAnnotations.endpoint, id_=capture_id, _external=True ), "mimetype": "application/json", **description_from_view(CaptureAnnotations), - }, + } + if CaptureAnnotations.endpoint + else {}, "download": { "href": url_for( CaptureDownload.endpoint, @@ -101,7 +107,9 @@ class CaptureSchema(ImageSchema): ), "mimetype": "image/jpeg", **description_from_view(CaptureDownload), - }, + } + if CaptureDownload.endpoint + else {}, } if isinstance(data, dict):