Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix space in custom migration #592

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
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]
2 changes: 1 addition & 1 deletion plone/app/contenttypes/migration/custom_migration.pt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<script type="text/javascript">
// function that toggle an icon by calling the p_viewName view
function getDXFields(at_typename, dx_typename) {
at_safe = at_typename.replace(' ', '_space_');
at_safe = at_typename.replaceAll(' ', '_space_');
$.ajax({
url: '@@display_dx_fields',
dataType: 'html',
Expand Down
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