Skip to content

Commit

Permalink
Fixed a bug in how validation schemas are applied
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon committed Oct 15, 2024
1 parent 08fb2f8 commit b59b433
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ This project adheres to semantic versioning.

### Removed

## [4.11.1] - 2024-10-15

### Changed
- Fixed a bug in the recent changes to instrument type and configuration type validation schemas

## [4.11.0] - 2024-10-11

### Changed
Expand Down
7 changes: 3 additions & 4 deletions observation_portal/observations/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ def validate(self, data):
if not target_serializer.is_valid():
raise serializers.ValidationError(target_serializer.errors)

for i, instrument_config in enumerate(validated_data['instrument_configs']):
configuration_type_validation_helper = ConfigurationTypeValidationHelper(data['instrument_type'], data['type'])
instrument_config = configuration_type_validation_helper.validate(instrument_config)
validated_data['instrument_configs'][i] = instrument_config

configuration_type_validation_helper = ConfigurationTypeValidationHelper(data['instrument_type'], data['type'])
validated_data = configuration_type_validation_helper.validate(validated_data)

return validated_data

Expand Down
4 changes: 2 additions & 2 deletions observation_portal/requestgroups/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,10 @@ def validate(self, data):

# Validate the instrument_type and configuration_type properties related validation schema at the configuration level
instrument_type_validation_helper = InstrumentTypeValidationHelper(instrument_type)
instrument_config = instrument_type_validation_helper.validate(data)
data = instrument_type_validation_helper.validate(data)

configuration_type_validation_helper = ConfigurationTypeValidationHelper(instrument_type, data['type'])
instrument_config = configuration_type_validation_helper.validate(data)
data = configuration_type_validation_helper.validate(data)

available_optical_elements = configdb.get_optical_elements(instrument_type)
for i, instrument_config in enumerate(data['instrument_configs']):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-ocs-observation-portal"
version = "4.11.0"
version = "4.11.1"
description = "The Observatory Control System (OCS) Observation Portal django apps"
license = "GPL-3.0-only"
authors = ["Observatory Control System Project <[email protected]>"]
Expand Down

0 comments on commit b59b433

Please sign in to comment.