Skip to content

Commit

Permalink
fixed replacement of blank with __space__ to match the key in the for…
Browse files Browse the repository at this point in the history
…m request;

added changelog in news to refer to the issue plone#305.
  • Loading branch information
gianni committed Mar 10, 2021
1 parent b7da966 commit 277115e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
6 changes: 6 additions & 0 deletions news/305.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
in custom_migration.migrate the form_dx_typename should contain _space_ to match the dx_key

the getDXFields javascript function doesn't replace all space in at_typename,
causing forms to non load right fields list, or not load it at all.

[gianniftp]
18 changes: 11 additions & 7 deletions plone/app/contenttypes/migration/custom_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def __call__(self):
raw_message = 'Migration applied successfully for {0} ' \
'"{1}" items.'
msg = translate(
raw_message.format(res_infos.get('counter'), res_type),
raw_message.format(
res_infos.get('counter'), res_type),
domain='plone.app.contenttypes',
)
messages.add(msg, type=u'info')
Expand Down Expand Up @@ -165,14 +166,15 @@ def getFieldsForATTypeWithFTI(self, typename):
return results
for field in schema.fields():
if not field.getName() in self.at_metadata_fields:
translated_label = translate(safe_unicode(field.widget.label))
translated_label = translate(
safe_unicode(field.widget.label))
results.append(
{'id': field.getName(),
'title': '{0} ({1})'.format(
translated_label,
field.getType()
),
'type': field.getType()}
),
'type': field.getType()}
)
return results

Expand All @@ -199,8 +201,8 @@ def getFieldsForATTypeWithoutFTI(self, typename):
'title': '{0} ({1})'.format(
translated_label,
field.getType()
),
'type': field.getType()}
),
'type': field.getType()}
)
return results

Expand Down Expand Up @@ -257,6 +259,8 @@ def migrate(self, dry_run=False):
form_dx_typename = form[k]
at_typename = form_at_typename.replace('_space_', ' ')
dx_typename = form_dx_typename.replace('_space_', ' ')
# the form_dx_typename should contain _space_ to match the dx_key
form_dx_typename.replace(' ', '_space_')

data[at_typename] = {'target_type': dx_typename,
'field_mapping': []}
Expand Down Expand Up @@ -296,7 +300,7 @@ def migrate(self, dry_run=False):
dst_type=data[at_typename]['target_type'],
dry_run=dry_run,
patch_searchabletext=patch_searchabletext,
)
)
migration_results.append({'type': at_typename,
'infos': res})
return migration_results
Expand Down

0 comments on commit 277115e

Please sign in to comment.