Skip to content

Commit

Permalink
Merge pull request #3982 from open-formulieren/feature/3688-v2-regist…
Browse files Browse the repository at this point in the history
…ration

[#3688] Add base logic to register submission with v2 options
  • Loading branch information
Viicos authored Mar 20, 2024
2 parents 77602e1 + 33f70df commit 2ea6685
Show file tree
Hide file tree
Showing 17 changed files with 711 additions and 39 deletions.
27 changes: 18 additions & 9 deletions docker/docker-compose.objects-apis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
version: '3'
version: '3.8'

name: objects-apis

services:
redis:
objects-redis:
image: redis:7
command: ["redis-server", "--appendonly", "yes"]
networks:
- open-forms-dev

db:
objects-objecttypes-db:
image: postgis/postgis:${PG_VERSION:-14-master}
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
Expand All @@ -21,10 +25,11 @@ services:
- DJANGO_SETTINGS_MODULE=objecttypes.conf.docker
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
- ALLOWED_HOSTS=*
- DB_HOST=objects-objecttypes-db
ports:
- 8001:8000
depends_on:
- db
- objects-objecttypes-db
networks:
- open-forms-dev

Expand All @@ -34,22 +39,26 @@ services:
- DJANGO_SETINGS_MODULE=objects.conf.docker
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
- ALLOWED_HOSTS=*
- DB_HOST=objects-objecttypes-db
- DISABLE_2FA=True
- CELERY_BROKER_URL=redis://objects-redis:6379/0
- CELERY_RESULT_BACKEND=redis://objects-redis:6379/0
- NOTIFICATIONS_DISABLED=True
ports:
- 8002:8000
depends_on:
- db
- redis
- objects-objecttypes-db
- objects-redis
networks:
- open-forms-dev

celery:
objects-celery:
image: maykinmedia/objects-api:${OBJECTS_VERSION:-2.3.0}
environment: *objects_web_env
command: /celery_worker.sh
depends_on:
- db
- redis
- objects-objecttypes-db
- objects-redis
networks:
- open-forms-dev

Expand Down
70 changes: 70 additions & 0 deletions docker/docker-compose.open-zaak.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: '3.8'

name: open-zaak

services:
openzaak-redis:
image: redis:7
command: ["redis-server", "--appendonly", "yes"]
networks:
- open-forms-dev

openzaak-db:
image: postgis/postgis:${PG_VERSION:-14-master}
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
- ./open-zaak/docker-init-open-zaak-db/:/docker-entrypoint-initdb.d
- open-zaak-db:/var/lib/postgresql/data
networks:
- open-forms-dev

openzaak-web.local:
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.11.0}
environment: &openzaak_web_env
- DJANGO_SETTINGS_MODULE=openzaak.conf.docker
- SECRET_KEY=${SECRET_KEY:-fgv=c0hz&tl*8*3m3893@m+1pstrvidc9e^5@fpspmg%cy$15d}
- ALLOWED_HOSTS=openzaak-web.local,localhost
- DB_NAME=openzaak
- DB_USER=openzaak
- DB_HOST=openzaak-db
- IS_HTTPS=no
- CACHE_DEFAULT=openzaak-redis:6379/0
- CACHE_AXES=openzaak-redis:6379/0
- SUBPATH=${SUBPATH:-/}
- OPENZAAK_SUPERUSER_USERNAME=admin
- DJANGO_SUPERUSER_PASSWORD=admin
- OPENZAAK_SUPERUSER_EMAIL=admin@localhost
- CELERY_BROKER_URL=redis://openzaak-redis:6379/1
- CELERY_RESULT_BACKEND=redis://openzaak-redis:6379/1
- NOTIFICATIONS_DISABLED=true
ports:
- 8003:8000
volumes: &openzaak_web_volumes
- media:/app/media # Shared media volume to get access to saved OAS files
- private-media:/app/private-media
depends_on:
- openzaak-db
- openzaak-redis
networks:
- open-forms-dev

celery:
image: openzaak/open-zaak:${OPENZAAK_VERSION:-1.11.0}
environment: *openzaak_web_env
volumes: *openzaak_web_volumes
command: /celery_worker.sh
depends_on:
- openzaak-db
- openzaak-redis
networks:
- open-forms-dev

volumes:
open-zaak-db:
media:
private-media:

networks:
open-forms-dev:
name: open-forms-dev
13 changes: 12 additions & 1 deletion docker/objects-apis/fixtures/objects_api_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
"administration": ""
}
},
{
"model": "token.permission",
"pk": 1,
"fields": {
"token_auth": "7657474c3d75f56ae0abd0d1bf7994b09964dca9",
"object_type": 1,
"mode": "read_and_write",
"use_fields": false,
"fields": null
}
},
{
"model": "zgw_consumers.service",
"pk": 1,
Expand All @@ -30,7 +41,7 @@
"oas_file": "",
"uuid": "ee08faa2-4cd1-45f6-ba16-d50872cf5cf2",
"api_type": "orc",
"api_root": "http://localhost:8001/api/v2/",
"api_root": "http://objecttypes-web:8000/api/v2/",
"client_id": "",
"secret": "",
"auth_type": "api_key",
Expand Down
30 changes: 22 additions & 8 deletions docker/objects-apis/fixtures/objecttypes_api_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,34 @@
"properties": {
"age": {
"type": "integer",
"minimum": 18,
"description": "Age in years which must be equal to or greater than 18."
"minimum": 18
},
"name": {
"type": "object",
"properties": {
"last.name": {"type": "string"}
}
},
"country": {
"submission_pdf_url": {
"type": "string",
"description": "The person's current country."
"format": "uri"
},
"lastName": {
"submission_csv_url": {
"type": "string",
"description": "The person's last name."
"format": "uri"
},
"firstName": {
"submission_payment_completed": {
"type": "boolean"
},
"submission_payment_amount": {
"type": "string"
},
"submission_payment_public_ids": {
"type": "array"
},
"submission_date": {
"type": "string",
"description": "The person's first name."
"format": "date-time"
}
}
},
Expand Down
21 changes: 21 additions & 0 deletions docker/open-zaak/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Open Zaak

The `docker-compose.open-zaak.yml` compose file is available to run an instance of Open Zaak.

## docker compose

Start an instance in your local environment from the parent directory:

```bash
docker compose -f docker-compose.open-zaak.yml up -d
```

This brings up the admin at http://localhost:8003/admin/.

## Load fixtures

Before re-recording the related VCR tests, you must load some fixtures:

```bash
cat open-zaak/fixtures/open_zaak_fixtures.json | docker compose -f docker-compose.open-zaak.yml exec -T openzaak-web.local src/manage.py loaddata --format=json -
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE USER openzaak;
CREATE DATABASE openzaak;
GRANT ALL PRIVILEGES ON DATABASE openzaak TO openzaak;
-- On Postgres 15+, connect to the database and grant schema permissions.
-- GRANT USAGE, CREATE ON SCHEMA public TO openzaak;
7 changes: 7 additions & 0 deletions docker/open-zaak/docker-init-open-zaak-db/0002-extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "openzaak" <<-EOSQL
CREATE EXTENSION postgis;
CREATE EXTENSION pg_trgm;
EOSQL
99 changes: 99 additions & 0 deletions docker/open-zaak/fixtures/open_zaak_fixtures.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[
{
"model": "authorizations.applicatie",
"pk": 1,
"fields": {
"uuid": "c2f70b46-14cc-4c22-87ce-31b72b83dd62",
"client_ids": "[\"test_client_id\"]",
"label": "test application",
"heeft_alle_autorisaties": true
}
},
{
"model": "vng_api_common.jwtsecret",
"pk": 1,
"fields": {
"identifier": "test_client_id",
"secret": "test_secret_key"
}
},
{
"model": "catalogi.catalogus",
"pk": 1,
"fields": {
"_etag": "a7068427bca54eb6f5e23d2b1f9961ff",
"naam": "Test catalog",
"uuid": "bd58635c-793e-446d-a7e0-460d7b04829d",
"domein": "TEST",
"rsin": "000000000",
"contactpersoon_beheer_naam": "Test name",
"contactpersoon_beheer_telefoonnummer": "",
"contactpersoon_beheer_emailadres": "",
"versie": "",
"begindatum_versie": null
}
},
{
"model": "catalogi.informatieobjecttype",
"pk": 1,
"fields": {
"_etag": "89c597c58e42b804148e6867c3480ed1",
"datum_begin_geldigheid": "2024-03-19",
"datum_einde_geldigheid": null,
"concept": false,
"uuid": "7a474713-0833-402a-8441-e467c08ac55b",
"omschrijving": "PDF Informatieobjecttype",
"informatieobjectcategorie": "Test category",
"trefwoord": "[]",
"vertrouwelijkheidaanduiding": "openbaar",
"omschrijving_generiek_informatieobjecttype": "",
"omschrijving_generiek_definitie": "",
"omschrijving_generiek_herkomst": "",
"omschrijving_generiek_hierarchie": "",
"omschrijving_generiek_opmerking": "",
"catalogus": 1
}
},
{
"model": "catalogi.informatieobjecttype",
"pk": 2,
"fields": {
"_etag": "89d53439caa01c2f00ab822679e80c7b",
"datum_begin_geldigheid": "2024-03-19",
"datum_einde_geldigheid": null,
"concept": false,
"uuid": "b2d83b94-9b9b-4e80-a82f-73ff993c62f3",
"omschrijving": "CSV Informatieobjecttype",
"informatieobjectcategorie": "Test category",
"trefwoord": "[]",
"vertrouwelijkheidaanduiding": "openbaar",
"omschrijving_generiek_informatieobjecttype": "",
"omschrijving_generiek_definitie": "",
"omschrijving_generiek_herkomst": "",
"omschrijving_generiek_hierarchie": "",
"omschrijving_generiek_opmerking": "",
"catalogus": 1
}
},
{
"model": "catalogi.informatieobjecttype",
"pk": 3,
"fields": {
"_etag": "783e0cef431e02aeb91d56074271d3c6",
"datum_begin_geldigheid": "2024-03-19",
"datum_einde_geldigheid": null,
"concept": false,
"uuid": "531f6c1a-97f7-478c-85f0-67d2f23661c7",
"omschrijving": "Attachment Informatieobjecttype",
"informatieobjectcategorie": "Test category",
"trefwoord": "[]",
"vertrouwelijkheidaanduiding": "openbaar",
"omschrijving_generiek_informatieobjecttype": "",
"omschrijving_generiek_definitie": "",
"omschrijving_generiek_herkomst": "",
"omschrijving_generiek_hierarchie": "",
"omschrijving_generiek_opmerking": "",
"catalogus": 1
}
}
]
12 changes: 11 additions & 1 deletion src/openforms/registrations/contrib/objects_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,19 @@ class ObjectsAPIOptionsSerializer(JsonSchemaSerializerMixin, serializers.Seriali
required=False,
)

# As `record.geometry` is outside `record.data`, we special case this attribute:
geometry_variable_key = FormioVariableKeyField(
label=_("geometry variable"),
help_text=_(
"The 'dotted' path to a form variable key that should be mapped to the `record.geometry` attribute."
),
required=False,
allow_blank=True,
)

def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:
v1_only_fields = {"content_json", "payment_status_update_json"}
v2_only_fields = {"variables_mapping"}
v2_only_fields = {"variables_mapping", "geometry_variable_key"}

version = get_from_serializer_data_or_instance("version", attrs, self)

Expand Down
9 changes: 3 additions & 6 deletions src/openforms/registrations/contrib/objects_api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,14 @@ def update_payment_status(
assert isinstance(config, ObjectsAPIConfig)
config.apply_defaults_to(options)

if not options["payment_status_update_json"]:
logger.warning(
"Skipping payment status update because no template was configured."
)
return

handler = HANDLER_MAPPING[options["version"]]
updated_object_data = handler.get_update_payment_status_data(
submission, options
)

if updated_object_data is None:
return

updated_object_data = {
"record": {
"data": updated_object_data,
Expand Down
Loading

0 comments on commit 2ea6685

Please sign in to comment.