Skip to content
Merged
1 change: 1 addition & 0 deletions doc/release/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
* [OSDEV-1589](https://opensupplyhub.atlassian.net/browse/OSDEV-1589) - Fixed layout issue on new `contribute` page.
* [OSDEV-1739](https://opensupplyhub.atlassian.net/browse/OSDEV-1739) - Applied state cleanup on modal unmount to prevent the same dialog from appearing when clicking on a different production location.
* [OSDEV-1744](https://opensupplyhub.atlassian.net/browse/OSDEV-1744) - Fixed the issue where the text `by user ID:` appeared even when `user_id` was `null` in Contribution Record page.
* [OSDEV-1778](https://opensupplyhub.atlassian.net/browse/OSDEV-1778) - Fixed the validation for number of workers field in POST, PATH production locations API. The min field must be less than or equal to the max field.

### What's new
* [OSDEV-1662](https://opensupplyhub.atlassian.net/browse/OSDEV-1662) - Added a new field, `action_perform_by`, to the moderation event. This data appears on the Contribution Record page when a moderator perform any actions like `APPROVED` or `REJECTED`.
Expand Down
18 changes: 18 additions & 0 deletions src/django/api/serializers/v1/number_of_workers_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,34 @@ class NumberOfWorkersSerializer(serializers.Serializer):
required=True,
error_messages={
'required': 'The min field is required!',
'invalid': 'The min field must be an integer.'
}
)
max = serializers.IntegerField(
min_value=1,
required=True,
error_messages={
'required': 'The max field is required!',
'invalid': 'The max field must be an integer.'
}
)

def validate(self, data):
min_value = data.get('min')
max_value = data.get('max')

if (
min_value is not None
and max_value is not None
and min_value > max_value
):
raise serializers.ValidationError(
{"min": ('The min field must be less than or equal'
' to the max field.')}
)

return data

@staticmethod
def validate_object(value):
return isinstance(value, dict)