Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ COPY \
./bin/report_component_problems.py \
./bin/fix_submission_value_variable_missing_fields.py \
./bin/fix_payment_status.py \
./bin/check_disable_next_logic_action.py \
./bin/report_completed_submissions_access.py \
./bin/report_invalid_form_logic.py \
Comment thread
viktorvanwijk marked this conversation as resolved.
./bin/report_logic_with_deprecated_clear_on_hide_behavior.py \
Expand Down
240 changes: 0 additions & 240 deletions bin/check_disable_next_logic_action.py

This file was deleted.

53 changes: 14 additions & 39 deletions bin/report_invalid_form_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
from __future__ import annotations

import sys
from collections.abc import Iterator
from pathlib import Path
from traceback import format_exc

import django
from django.db import transaction

from tabulate import tabulate

Expand All @@ -21,8 +18,10 @@ def report_invalid_forms() -> bool:
"""
Query forms that have new logic evaluation enabled but inconsistent logic rule
configuration.

In 4.0, this script will be used as an upgrade check, which means we can also
report forms that are not yet converted to new logic evalution at all.
"""
from openforms.forms.logic_analysis import CyclesDetected
from openforms.forms.models import Form

invalid_rules_detected = False
Expand All @@ -45,52 +44,28 @@ def report_invalid_forms() -> bool:
)
)

# check each individual form for logic rule cycles. Run this in a transaction and
# roll back, because apply_logic_analysis() saves the result to the DB.
# check if any forms still have new logic evaluation disabled
forms_to_check = Form.objects.filter(
_is_deleted=False,
new_logic_evaluation_enabled=False,
formlogic__isnull=False,
).distinct()

transaction.set_autocommit(False)
cycles_detected = False

def _detect_cycles() -> Iterator[tuple[int, str, bool, str]]:
nonlocal cycles_detected

for form in forms_to_check.iterator():
form.new_logic_evaluation_enabled = True
try:
form.apply_logic_analysis()
except CyclesDetected as exc:
variables = {var for cycle in exc.cycles for var in cycle.variables}
cycles_detected = True
yield (form.pk, form.admin_name, form.active, ", ".join(variables))
except Exception:
print(
f"Unexpected error in form {form.admin_name} ({form.pk}): "
f"{format_exc()}"
)

try:
non_converted_forms_detected = False
if forms_to_check.exists():
non_converted_forms_detected = True
print(
tabulate(
_detect_cycles(),
headers=("Form ID", "Form name", "Active", "Variables in cycles"),
)
"The following forms have have not been converted to the new logic "
"evaluation. Please review and change them to upgrade to Open Forms 4.0."
)
finally:
transaction.rollback()

if cycles_detected:
print(
"\nThe table above lists all the forms where cycles in logic rules were "
"detected. Please review and fix them as soon as possible. Open Forms 4.0 "
"will require this to be resolved before you can upgrade."
tabulate(
((form.pk, form.admin_name) for form in forms_to_check.iterator()),
headers=("Form ID", "Form name"),
)
)

return not invalid_rules_detected and not cycles_detected
return not invalid_rules_detected and not non_converted_forms_detected


def main(skip_setup=False) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions docs/installation/observability/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ see the :ref:`Submission <installation_observability_metrics_submissions>` metri
moved into the trash. Additional attributes are:

- ``scope`` - fixed, set to ``global`` to enable de-duplication.
- ``type`` - one of ``total``, ``live``, ``new_logic_evaluation_enabled``,
``translation_enabled``, ``is_regular``, ``is_appointment`` , ``is_single_step``
or ``trash``. For all but ``trash`` the forms in the trash are excluded.
- ``type`` - one of ``total``, ``live``, ``translation_enabled``, ``is_regular``,
``is_appointment`` , ``is_single_step`` or ``trash``. For all but ``trash`` the
forms in the trash are excluded.

``openforms.form_component_count``
Keeps track of how often a Formio component type is used in a form. This is only
Expand Down
28 changes: 28 additions & 0 deletions docs/installation/upgrade-400.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,31 @@ The default way to generate public references for the ZGW APIs registration plug
Previously, Open Forms always used case numbers as the submission public references.
Since Open Forms 3.5, both options have been available, but the default remained the ZGW API-generated
case numbers. The default is now switched to Open Forms-generated public references.

Logic engine rework
===================

.. note:: Relevant for: devops, form designers

The support for legacy logic evaluation has been removed, which means all forms will use the new logic evaluation.
Since Open Forms will now automatically assign all logic rules to the relevant form steps, it is also no longer
possible to specify a "trigger from step" for a logic rule.

TODO: this should probably a separate page describing the logic engine in more detail
For more information about the new logic evaluation, please refer to the
:ref:`detailed release notes of 3.5.0 <installation_upgrade_350>`.

.. warning::

Before upgrading, all existing forms should be converted to the new logic evaluation. This can be done on a
per-form basis, or in bulk using the following management command. Any forms which contain cycles in their
logic rules need to be resolved manually. The output of the management command will include relevant form
details if this is the case.

.. code-block:: bash

python /app/src/manage.py enable_new_logic_evaluation_for_all_forms

Clearing of values
Comment thread
vaszig marked this conversation as resolved.
------------------
TODO
Loading
Loading