Skip to content

Commit

Permalink
🚧 [#4908] Add processing of form variable options to JSON registratio…
Browse files Browse the repository at this point in the history
…n plugin

Need to include all form variables listed in the options to a values dictionary
  • Loading branch information
viktorvanwijk committed Dec 19, 2024
1 parent 037b928 commit c7e4837
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/openforms/registrations/contrib/json/plugin.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c7e4837

Please sign in to comment.