Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/4908 json registration backend #4956

Merged
merged 22 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8d34790
:construction: [#4908] WIP
viktorvanwijk Dec 17, 2024
b44aca4
:sparkles: [#4908] Add processing of form variable options to JSON re…
viktorvanwijk Dec 18, 2024
91d63a9
:white_check_mark: [#4908] Add tests
viktorvanwijk Dec 18, 2024
8b00df7
:sparkles: [#4908] Add processing of attachments in plugin
viktorvanwijk Dec 19, 2024
5370c8e
:sparkles: [#4908] Implement sending result to specified endpoint
viktorvanwijk Dec 19, 2024
4029b69
:sparkles: [#4908] Add docker compose flask app
viktorvanwijk Dec 20, 2024
75bcc5d
:sparkles: [#4908] Add typing hints for json registration options
viktorvanwijk Dec 20, 2024
cfa43a0
:sparkles: [#4908] Update JSON options serializer
viktorvanwijk Dec 20, 2024
d455de4
:sparkles: [#4908] Add checkbox to include variables from the variabl…
viktorvanwijk Dec 23, 2024
44783d2
:white_check_mark: [#4908] Add JSON registration plugin story to vari…
viktorvanwijk Dec 23, 2024
2c2abf9
:construction: [#4908] Add hard-coded schema to result dict in json r…
viktorvanwijk Jan 2, 2025
ac487c4
:art: [#4908] Fix imports and black code
viktorvanwijk Jan 2, 2025
12f5d78
:ok_hand: [#4908] Process PR feedback
viktorvanwijk Jan 2, 2025
55a4d25
:bug: [#4908] Fix bugs with JSON serializing
viktorvanwijk Jan 7, 2025
926964f
:bug: [#4908] Revise how attachments are processed
viktorvanwijk Jan 9, 2025
4233f5c
:alien: [#4908] Add validation for path
viktorvanwijk Jan 15, 2025
3ee8503
:truck: [#4908] Rename relative_api_endpoint to path
viktorvanwijk Jan 15, 2025
a48c922
:truck: [#4908] Rename form_variables to variables
viktorvanwijk Jan 15, 2025
e5229f1
:recycle: [#4908] Use VariableSelection component
viktorvanwijk Jan 16, 2025
13928d0
:white_check_mark: [#4908] Add and update tests
viktorvanwijk Jan 16, 2025
2500948
:globe_with_meridians: [#4908] Update translations
viktorvanwijk Jan 16, 2025
29b11fa
:ok_hand: [#4980] Process PR feedback
viktorvanwijk Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docker/docker-compose.json-dump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'

name: json-dump

services:
flask_app:
build: ./json-dump
ports:
- "80:80"
volumes:
- ./json-dump/:/app/

networks:
open-forms-dev:
name: open-forms-dev
17 changes: 17 additions & 0 deletions docker/json-dump/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official Python image from the Docker Hub
FROM python:3.12-slim

# Set the working directory
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install the dependencies
RUN pip install Flask

# Make port 80 available to the world outside this container
EXPOSE 80

# Run app.py when the container launches
CMD ["python", "app.py"]
18 changes: 18 additions & 0 deletions docker/json-dump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# JSON dump registration plugin

The `docker-compose.json-dump.yml` compose file is available to run a mock service intended
to simulate a receiving server to test the JSON dump registration backend plugin. It contains an
endpoint for sending json data (`json_plugin`) and testing the connection (`test_connection`).

The `json_plugin` endpoint returns a confirmation message that the data was received, together with the
received data. The `test_connection` endpoint just returns an 'OK' message.

## docker compose

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

```bash
docker compose -f docker-compose.json-dump.yml up -d
```

This starts a flask application at http://localhost:80/ with the endpoints `json_plugin` and `test_connection`.
23 changes: 23 additions & 0 deletions docker/json-dump/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json

from flask import Flask, jsonify, request

app = Flask(__name__)

@app.route("/json_plugin", methods=["POST"])
def json_plugin_post():
data = request.get_json()

app.logger.info(f"Data received: {data}")

message = "No data" if data is None else "Data received"
return jsonify({"message": message, "data": json.loads(data)}), 201


@app.route("/test_connection", methods=["GET"])
def test_connection():
return jsonify({"message": "OK"}), 200


if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, debug=True)
1 change: 1 addition & 0 deletions pyright.pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ include = [
# Registrations
"src/openforms/registrations/tasks.py",
"src/openforms/registrations/contrib/email/",
"src/openforms/registrations/contrib/json_dump/",
"src/openforms/registrations/contrib/stuf_zds/options.py",
"src/openforms/registrations/contrib/stuf_zds/plugin.py",
"src/openforms/registrations/contrib/stuf_zds/typing.py",
Expand Down
1 change: 1 addition & 0 deletions src/openforms/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"openforms.registrations.contrib.objects_api",
"openforms.registrations.contrib.microsoft_graph.apps.MicrosoftGraphApp",
"openforms.registrations.contrib.camunda.apps.CamundaApp",
"openforms.registrations.contrib.json_dump",
"openforms.prefill",
"openforms.prefill.contrib.demo.apps.DemoApp",
"openforms.prefill.contrib.kvk.apps.KVKPrefillApp",
Expand Down
54 changes: 54 additions & 0 deletions src/openforms/js/compiled-lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@
"value": "User defined"
}
],
"5rj0a+": [
{
"type": 0,
"value": "Service"
}
],
"5uaKBM": [
{
"type": 0,
Expand Down Expand Up @@ -1231,6 +1237,12 @@
"value": "Something went wrong while retrieving the available role types defined in the selected case. Please check that the services in the selected API group are configured correctly."
}
],
"AkG8Zu": [
{
"type": 0,
"value": "Plugin configuration: JSON"
}
],
"AtBVAV": [
{
"type": 0,
Expand Down Expand Up @@ -1523,6 +1535,12 @@
"value": "length"
}
],
"CZ774U": [
{
"type": 0,
"value": "Which variables to include in the data to be sent"
}
],
"Cf5zSF": [
{
"type": 0,
Expand Down Expand Up @@ -2245,6 +2263,12 @@
"value": " is unknown. We can only display the JSON definition."
}
],
"Ibejpf": [
{
"type": 0,
"value": "Path relative to the Service API root"
}
],
"Igt0Rc": [
{
"type": 0,
Expand Down Expand Up @@ -2487,6 +2511,12 @@
"value": "Manually defined"
}
],
"Kl9yvd": [
{
"type": 0,
"value": "Path"
}
],
"KrJ+rN": [
{
"type": 0,
Expand Down Expand Up @@ -2883,6 +2913,12 @@
"value": "Advanced"
}
],
"OpkUgV": [
{
"type": 0,
"value": "Whether to include this variable in the data to be sent."
}
],
"Orf0vr": [
{
"type": 0,
Expand Down Expand Up @@ -3803,6 +3839,12 @@
"value": "Remove"
}
],
"XyDeaD": [
{
"type": 0,
"value": "Variables"
}
],
"Y4oNhH": [
{
"type": 0,
Expand Down Expand Up @@ -5673,6 +5715,12 @@
"value": "Something went wrong while retrieving the available object type versions."
}
],
"nZZkHx": [
{
"type": 0,
"value": "Include variable"
}
],
"neCqv9": [
{
"type": 0,
Expand Down Expand Up @@ -5985,6 +6033,12 @@
"value": "This template is evaluated with the submission data when the payment is received. The resulting JSON is sent to the objects API to update (the payment fields of) the earlier created object."
}
],
"qPiUic": [
{
"type": 0,
"value": "Which service to send the data to"
}
],
"qUYLVg": [
{
"type": 0,
Expand Down
54 changes: 54 additions & 0 deletions src/openforms/js/compiled-lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@
"value": "Gebruikersvariabelen"
}
],
"5rj0a+": [
{
"type": 0,
"value": "Service"
}
],
"5uaKBM": [
{
"type": 0,
Expand Down Expand Up @@ -1235,6 +1241,12 @@
"value": "Er ging iets fout bij het ophalen van de beschikbare roltypen in het geselecteerde zaaktype. Controleer of de services in de geselecteerde API-groep goed ingesteld zijn."
}
],
"AkG8Zu": [
{
"type": 0,
"value": "Plugin configuration: JSON"
}
],
"AtBVAV": [
{
"type": 0,
Expand Down Expand Up @@ -1527,6 +1539,12 @@
"value": "length"
}
],
"CZ774U": [
{
"type": 0,
"value": "Which variables to include in the data to be sent"
}
],
"Cf5zSF": [
{
"type": 0,
Expand Down Expand Up @@ -2266,6 +2284,12 @@
"value": " is niet bekend. We kunnen enkel de JSON-definitie weergeven."
}
],
"Ibejpf": [
{
"type": 0,
"value": "Path relative to the Service API root"
}
],
"Igt0Rc": [
{
"type": 0,
Expand Down Expand Up @@ -2504,6 +2528,12 @@
"value": "Handmatig ingesteld"
}
],
"Kl9yvd": [
{
"type": 0,
"value": "Path"
}
],
"KrJ+rN": [
{
"type": 0,
Expand Down Expand Up @@ -2900,6 +2930,12 @@
"value": "Geavanceerd"
}
],
"OpkUgV": [
{
"type": 0,
"value": "Whether to include this variable in the data to be sent."
}
],
"Orf0vr": [
{
"type": 0,
Expand Down Expand Up @@ -3816,6 +3852,12 @@
"value": "Verwijderen"
}
],
"XyDeaD": [
{
"type": 0,
"value": "Variables"
}
],
"Y4oNhH": [
{
"type": 0,
Expand Down Expand Up @@ -5691,6 +5733,12 @@
"value": "Er ging iets fout bij het ophalen van de objecttypeversies."
}
],
"nZZkHx": [
{
"type": 0,
"value": "Include variable"
}
],
"neCqv9": [
{
"type": 0,
Expand Down Expand Up @@ -6003,6 +6051,12 @@
"value": "Dit sjabloon wordt geëvalueerd met de inzendingsgegevens wanneer de betaling ontvangen is. De resulterende JSON wordt naar de Objecten-API gestuurd om (de betaalattributen van) het eerder aangemaakte object bij te werken."
}
],
"qPiUic": [
{
"type": 0,
"value": "Which service to send the data to"
}
],
"qUYLVg": [
{
"type": 0,
Expand Down
Loading
Loading