2.5.2/fix/validation + drag&drop - #1689
Conversation
|
Drag an element at top of the section is only possible if dragging it on the upper element. DragAndDrop.mp4 |
|
The tests fail, I think there is some hard-code thing of the old serializer style in it: =========================== short test summary info ============================
FAILED rdmo/core/tests/test_validators.py::test_instance_validator - AttributeError: 'InstanceValidator' object has no attribute 'serializer'
FAILED rdmo/core/tests/test_validators.py::test_instance_validator_serializer_instance - TypeError: 'InstanceValidator' object is not callable
FAILED rdmo/core/tests/test_validators.py::test_instance_validator_serializer - TypeError: 'InstanceValidator' object is not callable
FAILED rdmo/core/tests/test_validators.py::test_instance_validator_instance - AttributeError: 'InstanceValidator' object has no attribute 'serializer'
FAILED rdmo/core/tests/test_validators.py::test_instance_validator_validation_serializer_error - TypeError: 'InstanceValidator' object is not callable |
|
Ok, now it should work as expected. You can even move a question in a page from a questionset by targeting the small difference in indent where the page drop zone is but the question set drop zone isn't. |
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
| if data.get('locked', False) and self.instance and self.instance.locked: | ||
| locked = self.get_value(data, instance, 'locked') | ||
| if locked and instance is not None and instance.locked: | ||
| if data.get('locked'): |
There was a problem hiding this comment.
I think that this line (if data.get('locked'):) needs to be removed since this partial update feature, since how would it be possible that the following test did not raise the validation error ??!
def test_serializer_update_partial_error(db):
attribute = Attribute.objects.get(uri='http://example.com/terms/domain/individual/single/text')
attribute.locked = True
attribute.save()
validator = AttributeLockedValidator()
serializer = AttributeSerializer(instance=attribute, partial=True)
with pytest.raises(RestFrameworkValidationError):
validator({
'comment': 'Updated comment'
}, serializer)and pytest showed:
E Failed: DID NOT RAISE ValidationError
There was a problem hiding this comment.
Nice catch! I fixed it and added some more tests.
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
MyPyDavid
left a comment
There was a problem hiding this comment.
Thanks this fixes it and drops nicely!
Ive added one more commit for changing toggle-site also to PATCH.
| const toggleAvailable = () => elementActions.patchElement('catalogs', { id: catalog.id, available: !catalog.available }) | ||
| const toggleLocked = () => elementActions.patchElement('catalogs', { id: catalog.id, locked: !catalog.locked }) | ||
|
|
||
| const toggleCurrentSite = () => elementActions.storeElement('catalogs', catalog, 'toggle-site') |
There was a problem hiding this comment.
I think it would also fit to use the patchElement action for the toggleCurrentSite so I've added it (in one commit for Catalog, View and Task)
remove elementAction from storeElement.
|
Ok, I think its less complex now. I removed the action from |
This PR aims to fix three things:
Resolve Drag and drop/available/locked not working in nested catalog view #1685, by using
PATCHfor the drag and drop as well aslocked/available(introducing dedicated actions forpatchElement).Fixing an issue Claude pointed be to: Validators used by serializers are initialized at startup and are not copied for each request. Setting
self.instanceandself.serializeron the validator instances is therefore faulty. All requests write into the same attribute of the same instance. The solution is to process theserializerarg provided to__call__.For
PATCHrequests, where only (small) parts of the instance is indata, missing values from the instance which is updated should be used for validation. This is done by using the newget_valuesmethod inInstanceValidator.