Skip to content

Commit

Permalink
Update implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ammar257ammar committed Dec 12, 2024
1 parent ce9b716 commit 7c51fff
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions app/grandchallenge/hanging_protocols/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,14 @@ def __init__(self, *args, **kwargs):
def clean_json(self):
hanging_protocol_json = self.cleaned_data["json"]

if not isinstance(hanging_protocol_json, list):
return hanging_protocol_json

viewport_names = [
viewport["viewport_name"]
for viewport in hanging_protocol_json
if isinstance(viewport, dict) and "viewport_name" in viewport
]

if not viewport_names:
return hanging_protocol_json
try:
viewport_names = [
viewport["viewport_name"] for viewport in hanging_protocol_json
]
except (KeyError, TypeError):
raise ValidationError(
"Hanging protocol definition is invalid. Have a look at the example in the helptext."
)

self._validate_viewport_uniqueness(viewport_names=viewport_names)
self._validate_dimensions(value=hanging_protocol_json)
Expand Down

0 comments on commit 7c51fff

Please sign in to comment.