diff --git a/src/openforms/registrations/contrib/json/plugin.py b/src/openforms/registrations/contrib/json/plugin.py index 2474fe1a01..0cd7b55278 100644 --- a/src/openforms/registrations/contrib/json/plugin.py +++ b/src/openforms/registrations/contrib/json/plugin.py @@ -1,18 +1,37 @@ from django.utils.translation import gettext_lazy as _ from openforms.submissions.models import Submission +from openforms.variables.service import get_static_variables + from ...base import BasePlugin, OptionsT # openforms.registrations.base from ...registry import register # openforms.registrations.registry from .config import JSONOptionsSerializer @register("json") -class JSONPlugin(BasePlugin): +class JSONRegistration(BasePlugin): verbose_name = _("JSON registration") configuration_options = JSONOptionsSerializer def register_submission(self, submission: Submission, options: OptionsT) -> None: - print(options) + static_variables = get_static_variables(submission=submission) + static_variables_dict = { + variable.key: variable.initial_value for variable in static_variables + } + + # TODO-4908: what should the behaviour be when a form + # variable is not in the data or static variables? + values = { + form_variable: submission.data.get( + form_variable, static_variables_dict.get(form_variable) + ) + for form_variable in options["form_variables"] + } + + print(values) + + # TODO-4908: send `values` to some service + data_to_be_sent = {"values": values} def check_config(self): pass