Skip to content

Commit

Permalink
Merge pull request #4856 from open-formulieren/cleanup/4771-remove-pr…
Browse files Browse the repository at this point in the history
…ice-logic

Replace form price logic with variable + normal logic
  • Loading branch information
sergei-maertens authored Nov 28, 2024
2 parents de45256 + bf46b3e commit f0aa235
Show file tree
Hide file tree
Showing 30 changed files with 537 additions and 990 deletions.
4 changes: 2 additions & 2 deletions docs/installation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ and expertise.
form_hosting
redis
issues/index
upgrade-240
upgrade-250
upgrade-300
upgrade-250
upgrade-240
70 changes: 60 additions & 10 deletions docs/installation/upgrade-300.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,66 @@
Upgrade details to Open Forms 3.0.0
===================================

Backwards compatibility in form import changes
==============================================

Removal of Object API object type convertion
--------------------------------------------
Open Forms 3.0 is a major version release that contains some breaking changes. As always
we try to limit the impact of breaking changes through automatic migrations, and this
release is no different, but there are some subtle changes in behaviour that you should
be aware of, as they may require additional manual actions.

With the UX changes of OF 2.8.0, the Object Api registration no longer lets you use
hyperlinks when configuring the object type. The usage of hyperlinks for the object type
is now also disallowed when importing a form.
.. contents:: Jump to
:depth: 1
:local:

Previously the hyperlinks would be converted to the expected format, and saved as such.
The convertion will no-longer take place, and the 'to be imported' form is expected to
use the new UUID format for the object type.
Removal of price logic
======================

Price logic rules are removed in favour of setting the submission price via a form
variable and normal logic rules. The conversion is automatic.

There is a slight change in behaviour. When no price logic rules matched the trigger
condition, the price set on the related product was used. This can lead to surprises
and wrong amounts being paid due to logical errors in the form itself.

The new behaviour will (deliberately) cause a crash that will show to the end-user
as "something unexpectedly went wrong", since we refuse to make any (likely wrong)
assumptions about the amount that needs to be paid. Crash information is visible
in the error monitoring if that's set up correctly.

.. note:: Existing, automatically converted forms are crash-free because we create an
explicit fallback logic rule that mimicks the old behaviour.

Form components/fields changes
==============================

Password component removed
--------------------------

The password component was deprecated a long time ago, and has now been removed. If you
need to replace it anywhere, use a regular textfield component instead, but you really
shouldn't be asking users for passwords.

Removed import conversions
==========================

For a number of changes, Open Forms ensured that old form exports could still be
imported and would automatically convert some data. Some of these conversion have been
removed.

Removal of objecttype URL conversion in the Objects API registration options
----------------------------------------------------------------------------

Since the UX improvments in Open Forms 2.8.0 you can select the object type in a
dropdown, and under the hood we save the unique identifier rather than the full API
resource URL (which you used to have to copy-paste in a text field). The usage of
hyperlinks for the object type is now also disallowed when importing a form.

Previously the hyperlinks would be converted to the expected format, and saved as such,
which was quite complex and not ideal for exports using the new format. We
recommend re-creating the exports on a newer version of Open Forms.

Removal of legacy translations conversion
-----------------------------------------

Old (from before Open Forms 2.4) form export files containing form field translations
in the legacy format are now ignored instead of converted to the new format. We
recommend re-creating the exports on a newer version of Open Forms.
9 changes: 4 additions & 5 deletions docs/manual/forms/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ product bevat een prijs die gebruikt kan worden als betaald moet worden voor
het product. Betaling kan ingesteld worden door de juiste **Betaalprovider** te
selecteren.

Er zijn drie manieren om de prijs van een inzending te bepalen:
Er zijn twee manieren om de prijs van een inzending te bepalen:

**Gebruik de prijs van het gekoppeld product**

Expand All @@ -226,10 +226,9 @@ te activeren.

**Gebruik prijslogica**

Voor eenvoudige condities kan je prijslogic instellen. Onder een bepaalde conditie geldt
een bepaalde, vaste, prijs. Indien aan geen enkele conditie voldaan is, dan wordt de
prijs van het gekoppeld product gebruikt. De **Prijslogica** volgt verder dezelfde
regels als reguliere **Logica**.
.. versionremoved:: 3.0

De prijslogica is vervangen door gewone logica + gebruik van een variabele.

Zie ook: :ref:`configuration_payment_index`

Expand Down
253 changes: 0 additions & 253 deletions src/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2512,229 +2512,6 @@ paths:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
/api/v2/forms/{uuid_or_slug}/price-logic-rules:
get:
operationId: forms_price_logic_rules_list
description: List all price logic rules defined for a form.
summary: List price logic rules
parameters:
- in: path
name: uuid_or_slug
schema:
type: integer
description: A unique integer value identifying this form.
required: true
tags:
- logic-rules
security:
- tokenAuth: []
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/FormPriceLogic'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/Exception'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/Exception'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/Exception'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'405':
content:
application/json:
schema:
$ref: '#/components/schemas/Exception'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
put:
operationId: forms_price_logic_rules_update
description: By sending a list of FormPriceLogic to this endpoint, all the FormPriceLogic
related to the form will be replaced with the data sent to the endpoint.
summary: Bulk configure price logic rules
parameters:
- in: header
name: X-CSP-Nonce
schema:
type: string
description: The value of the CSP nonce generated by the page embedding the
SDK. If provided, fields containing rich text from WYSIWYG editors will
be post-processed to allow inline styles with the provided nonce. If the
embedding page emits a `style-src` policy containing `unsafe-inline`, then
you can omit this header without losing functionality. We recommend favouring
the nonce mechanism though.
- in: path
name: uuid_or_slug
schema:
type: integer
description: A unique integer value identifying this form.
required: true
tags:
- logic-rules
requestBody:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/FormPriceLogic'
required: true
security:
- tokenAuth: []
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/FormPriceLogic'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'401':
content:
application/json:
schema:
$ref: '#/components/schemas/Exception'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/Exception'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/Exception'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
'405':
content:
application/json:
schema:
$ref: '#/components/schemas/Exception'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
/api/v2/forms/{uuid_or_slug}/variables:
get:
operationId: forms_variables_list
Expand Down Expand Up @@ -8471,36 +8248,6 @@ components:
title: Explanation template [nl]
description: Content that will be shown on the start page of the form, below
the title and above the log in text.
FormPriceLogic:
type: object
properties:
uuid:
type: string
format: uuid
readOnly: true
url:
type: string
format: uri
readOnly: true
form:
type: string
format: uri
description: Form to which the pricing JSON logic applies.
jsonLogicTrigger:
title: JSON logic
description: The trigger expression to determine if the actions should execute
or not. Note that this must be a valid JsonLogic expression, and the first
operand must be a reference to a variable in the form.
price:
type: string
format: decimal
pattern: ^-?\d{0,8}(?:\.\d{0,2})?$
required:
- form
- jsonLogicTrigger
- price
- url
- uuid
FormRegistrationBackend:
type: object
properties:
Expand Down
2 changes: 0 additions & 2 deletions src/openforms/forms/api/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
from .form_variable import FormVariableListSerializer, FormVariableSerializer
from .form_version import FormVersionSerializer
from .logic.form_logic import FormLogicSerializer
from .logic.form_logic_price import FormPriceLogicSerializer

__all__ = [
"FormLogicSerializer",
"FormPriceLogicSerializer",
"FormSerializer",
"FormExportSerializer",
"FormImportSerializer",
Expand Down
Loading

0 comments on commit f0aa235

Please sign in to comment.