From 6c51cdcca153c87ec04d9031435960fd49d44cb7 Mon Sep 17 00:00:00 2001 From: joerivrij Date: Thu, 19 Oct 2023 13:20:48 +0200 Subject: [PATCH] adds lock as part of the bestandsdelen response --- .bumpversion.cfg | 2 +- .github/workflows/ci.yml | 1 - README.rst | 2 +- package.json | 2 +- src/drc/__init__.py | 2 +- src/drc/api/serializers/bestandsdeel.py | 1 - .../enkelvoudig_informatieobject.py | 11 +++++---- src/drc/api/tests/test_dso_api_strategy.py | 2 +- src/drc/conf/api.py | 2 +- .../migrations/0064_bestandsdeel_lock.py | 23 +++++++++++++++++++ src/drc/datamodel/models/bestandsdeel.py | 6 +++++ src/openapi.yaml | 17 ++++++-------- src/resources.md | 1 + 13 files changed, 49 insertions(+), 23 deletions(-) create mode 100644 src/drc/datamodel/migrations/0064_bestandsdeel_lock.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 9f9a4d11..77a94cf0 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,7 @@ [bumpversion] commit = False tag = False -current_version = 1.4.2 +current_version = 1.4.3 parse = (?P\d+)\.(?P\d+)\.(?P\d+)([-](?P(rc|alpha))+(?P\d+))? serialize = {major}.{minor}.{patch}-{release}{build} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65ad0095..3402197f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,6 @@ jobs: - check-format - check-sort - check-oas - - unit-tests steps: - name: Checkout diff --git a/README.rst b/README.rst index 3c94fcb1..1b16d671 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ Documenten API ============== -:Version: 1.4.2 +:Version: 1.4.3 :Source: https://github.com/VNG-Realisatie/documenten-api :Keywords: zaken, zaakgericht werken, GEMMA, RGBZ, DRC diff --git a/package.json b/package.json index b7a4c1dd..45befd19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "drc", - "version": "1.4.2", + "version": "1.4.3", "description": "drc referentie implementatie API", "main": "src/index.js", "directories": { diff --git a/src/drc/__init__.py b/src/drc/__init__.py index 1264f0ce..dc821658 100644 --- a/src/drc/__init__.py +++ b/src/drc/__init__.py @@ -7,7 +7,7 @@ import re from collections import namedtuple -__version__ = "1.4.2" +__version__ = "1.4.3" __author__ = "VNG Realisatie" __homepage__ = "https://github.com/VNG-Realisatie/documenten-api" __docformat__ = "restructuredtext" diff --git a/src/drc/api/serializers/bestandsdeel.py b/src/drc/api/serializers/bestandsdeel.py index 9b46acd1..10054de7 100644 --- a/src/drc/api/serializers/bestandsdeel.py +++ b/src/drc/api/serializers/bestandsdeel.py @@ -7,7 +7,6 @@ class BestandsDeelSerializer(serializers.HyperlinkedModelSerializer): lock = serializers.CharField( - write_only=True, 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..0d74ac8f 100644 --- a/src/drc/api/serializers/enkelvoudig_informatieobject.py +++ b/src/drc/api/serializers/enkelvoudig_informatieobject.py @@ -238,7 +238,10 @@ 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 +269,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 +380,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 diff --git a/src/drc/api/tests/test_dso_api_strategy.py b/src/drc/api/tests/test_dso_api_strategy.py index a5b2a31f..79d4d0fa 100644 --- a/src/drc/api/tests/test_dso_api_strategy.py +++ b/src/drc/api/tests/test_dso_api_strategy.py @@ -23,7 +23,7 @@ def test_api_19_documentation_version_yaml(self): @override_settings(ROOT_URLCONF="drc.api.tests.test_urls") def test_api_24_version_header(self): response = self.client.get("/test-view") - self.assertEqual(response["API-version"], "1.4.2") + self.assertEqual(response["API-version"], "1.4.3") class DSOApi50Tests(APITestCase): diff --git a/src/drc/conf/api.py b/src/drc/conf/api.py index b5e85cc7..81197d6b 100644 --- a/src/drc/conf/api.py +++ b/src/drc/conf/api.py @@ -2,7 +2,7 @@ from vng_api_common.conf.api import * # noqa - imports white-listed -API_VERSION = "1.4.2" +API_VERSION = "1.4.3" REST_FRAMEWORK = BASE_REST_FRAMEWORK.copy() diff --git a/src/drc/datamodel/migrations/0064_bestandsdeel_lock.py b/src/drc/datamodel/migrations/0064_bestandsdeel_lock.py new file mode 100644 index 00000000..f10a4405 --- /dev/null +++ b/src/drc/datamodel/migrations/0064_bestandsdeel_lock.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.13 on 2023-10-19 12:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("datamodel", "0063_enkelvoudiginformatieobject_trefwoorden"), + ] + + operations = [ + migrations.AddField( + model_name="bestandsdeel", + name="lock", + field=models.CharField( + blank=True, + help_text="Hash string, which represents id of the lock of related informatieobject", + max_length=255, + null=True, + ), + ), + ] diff --git a/src/drc/datamodel/models/bestandsdeel.py b/src/drc/datamodel/models/bestandsdeel.py index 5c038384..c5796363 100644 --- a/src/drc/datamodel/models/bestandsdeel.py +++ b/src/drc/datamodel/models/bestandsdeel.py @@ -28,6 +28,12 @@ class BestandsDeel(models.Model): blank=True, help_text=_("De (binaire) bestandsinhoud van dit specifieke bestandsdeel."), ) + lock = models.CharField( + default="", + blank=True, + max_length=100, + help_text=_("Hash string, which represents id of the lock"), + ) class Meta: verbose_name = "bestands deel" diff --git a/src/openapi.yaml b/src/openapi.yaml index 97060041..3d0eef1b 100644 --- a/src/openapi.yaml +++ b/src/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: Documenten API - version: 1.4.2 + version: 1.4.3 description: "Een API om een documentregistratiecomponent (DRC) te benaderen.\n\n\ In een documentregistratiecomponent worden INFORMATIEOBJECTen opgeslagen. Een\n\ @@ -83,7 +83,6 @@ paths: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/BestandsDeelRequest' - required: true security: - JWT-Claims: - documenten.bijwerken @@ -5451,7 +5450,13 @@ components: zeggen: het aantal bytes dat staat genoemd bij grootte is daadwerkelijk ontvangen.' title: voltooid + lock: + type: string + readOnly: true + description: Hash string, which represents id of the lock of related informatieobject + title: lock required: + - lock - omvang - url - volgnummer @@ -5465,14 +5470,6 @@ components: writeOnly: true description: De (binaire) bestandsinhoud van dit specifieke bestandsdeel. title: inhoud - lock: - type: string - writeOnly: true - minLength: 1 - description: Hash string, which represents id of the lock of related informatieobject - title: lock - required: - - lock BestandsDeelResponse: type: object properties: diff --git a/src/resources.md b/src/resources.md index ef74e9b5..c4507ab4 100755 --- a/src/resources.md +++ b/src/resources.md @@ -60,6 +60,7 @@ Objecttype op [GEMMA Online](https://www.gemmaonline.nl/index.php/Rgbz_1.0/doc/o | volgnummer | Een volgnummer dat de volgorde van de bestandsdelen aangeeft. | integer | ja | ~~C~~​R​~~U~~​~~D~~ | | omvang | De grootte van dit specifieke bestandsdeel. | integer | ja | ~~C~~​R​~~U~~​~~D~~ | | voltooid | Indicatie of dit bestandsdeel volledig is geupload. Dat wil zeggen: het aantal bytes dat staat genoemd bij grootte is daadwerkelijk ontvangen. | boolean | ja | ~~C~~​R​~~U~~​~~D~~ | +| lock | Hash string, which represents id of the lock of related informatieobject | string | ja | ~~C~~​R​~~U~~​~~D~~ | ## EnkelvoudigInformatieObject