diff --git a/src/drc/api/serializers/bestandsdeel.py b/src/drc/api/serializers/bestandsdeel.py index 12c3c6b3..10054de7 100644 --- a/src/drc/api/serializers/bestandsdeel.py +++ b/src/drc/api/serializers/bestandsdeel.py @@ -7,8 +7,6 @@ class BestandsDeelSerializer(serializers.HyperlinkedModelSerializer): lock = serializers.CharField( - read_only=True, - source="canonical.lock", help_text="Hash string, which represents id of the lock of related informatieobject", ) diff --git a/src/drc/api/serializers/enkelvoudig_informatieobject.py b/src/drc/api/serializers/enkelvoudig_informatieobject.py index 4d17de29..689e88fd 100644 --- a/src/drc/api/serializers/enkelvoudig_informatieobject.py +++ b/src/drc/api/serializers/enkelvoudig_informatieobject.py @@ -238,7 +238,7 @@ def _create_bestandsdeel(self, full_size, canonical): for i in range(parts): chunk_size = min(settings.CHUNK_SIZE, full_size) BestandsDeel.objects.create( - informatieobject=canonical, omvang=chunk_size, volgnummer=i + 1 + informatieobject=canonical, omvang=chunk_size, volgnummer=i + 1, lock=canonical.lock ) full_size -= chunk_size @@ -266,10 +266,6 @@ def create(self, validated_data): eio.ondertekening = ondertekening eio.save() - # large file process - if not eio.inhoud and eio.bestandsomvang and eio.bestandsomvang > 0: - self._create_bestandsdeel(validated_data["bestandsomvang"], canonical) - # create empty file if size == 0 if eio.bestandsomvang == 0: eio.inhoud.save("empty_file", ContentFile("")) @@ -381,6 +377,8 @@ def create(self, validated_data): # lock document if it is a large file upload if not eio.inhoud and eio.bestandsomvang and eio.bestandsomvang > 0: eio.canonical.lock = uuid.uuid4().hex + # large file process + self._create_bestandsdeel(validated_data["bestandsomvang"], eio.canonical) eio.canonical.save() return eio