-
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.
✨ [#2344] Add migration to change hideLabel setting
- Loading branch information
1 parent
ae3faba
commit e612002
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/openforms/forms/migrations/0055_make_hidelabel_false.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,37 @@ | ||
# Generated by Django 3.2.16 on 2022-11-17 16:46 | ||
from django.db import migrations | ||
|
||
from openforms.formio.utils import iter_components | ||
|
||
|
||
def make_hide_label_false(apps, _): | ||
FormDefinition = apps.get_model("forms", "FormDefinition") | ||
|
||
form_definitions = FormDefinition.objects.all() | ||
form_definitions_to_update = [] | ||
for form_definition in form_definitions: | ||
updated_form_definition = False | ||
for comp in iter_components(configuration=form_definition.configuration): | ||
if comp["type"] != "editgrid" or not comp.get("hideLabel", False): | ||
continue | ||
comp["hideLabel"] = False | ||
updated_form_definition = True | ||
|
||
if updated_form_definition: | ||
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", "0054_merge_20221114_1308"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(make_hide_label_false, migrations.RunPython.noop), | ||
] |