-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3479 from open-formulieren/fix/3443-date-validation
[#3443] Date validation
- Loading branch information
Showing
5 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/openforms/forms/migrations/0093_date_component_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 3.2.21 on 2023-09-13 08:24 | ||
|
||
from django.db import migrations | ||
from openforms.formio.utils import iter_components | ||
|
||
|
||
def add_date_component_settings(apps, schema_editor): | ||
FormDefinition = apps.get_model("forms", "FormDefinition") | ||
|
||
form_definitions = FormDefinition.objects.all() | ||
|
||
form_definitions_to_update = [] | ||
for form_definition in form_definitions: | ||
for comp in iter_components(configuration=form_definition.configuration): | ||
if comp["type"] == "date": | ||
if translated_errors := comp.get("translatedErrors"): | ||
for ( | ||
language_code, | ||
custom_error_messages, | ||
) in translated_errors.items(): | ||
translated_errors[language_code]["minDate"] = "" | ||
translated_errors[language_code]["maxDate"] = "" | ||
|
||
comp.setdefault("customOptions", {}) | ||
comp["customOptions"]["allowInvalidPreload"] = True | ||
|
||
form_definitions_to_update.append(form_definition) | ||
|
||
if form_definitions_to_update: | ||
FormDefinition.objects.bulk_update( | ||
form_definitions_to_update, fields=["configuration"] | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("forms", "0092_more_time_custom_errors"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(add_date_component_settings, migrations.RunPython.noop) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters