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

Add context to translation payload when dealing with TextPlugin #452

Merged
merged 10 commits into from Jan 15, 2018

Conversation

filwaitman
Copy link
Contributor

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.0%) to 77.633% when pulling 8e26b0d on bug/fix-context-translation2 into d758650 on master.

1 similar comment
@coveralls
Copy link

coveralls commented Jan 4, 2018

Coverage Status

Coverage decreased (-1.0%) to 77.633% when pulling 8e26b0d on bug/fix-context-translation2 into d758650 on master.

.python-version

# celery beat schedule file
celerybeat-schedule
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sanity, I'm using the default .gitignore for python porvided by github. =]

@staticmethod
def get_translation_content(field, plugin_data):
def _render_plugin_with_content(obj, match):
field = django_settings.DJANGOCMS_TRANSLATIONS_CONF[obj.plugin_type]['text_field_child_label']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call the helper mentioned in my comment on translations app

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I (1) duplicate the method in this project or (2) assume djangocms-translations is installed in this context?

I would go for (2).


OBJ_ADMIN_RE_PATTERN_WITH_CONTENT = _rreplace(OBJ_ADMIN_RE_PATTERN, '.*?', '(?P<content>.*?)', 1)
data = [x.groups() for x in re.finditer(OBJ_ADMIN_RE_PATTERN_WITH_CONTENT, content)]
data = {int(k): v for k, v in data}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data = {int(pk): value for pk, value in data}

def _rreplace(text, old, new, count):
return new.join(text.rsplit(old, count))

OBJ_ADMIN_RE_PATTERN_WITH_CONTENT = _rreplace(OBJ_ADMIN_RE_PATTERN, '.*?', '(?P<content>.*?)', 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at he cost of DRY, please make a constant with the necessary regex.

return content, subplugins_within_this_content

@staticmethod
def get_translation_children_content(content, plugin):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_translation_import_content

@@ -197,6 +202,31 @@ def do_post_copy(self, instance, source_map):
new_text = replace_plugin_tags(instance.body, ids_map)
self.model.objects.filter(pk=instance.pk).update(body=new_text)

@staticmethod
def get_translation_content(field, plugin_data):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_translation_import_content


@python_2_unicode_compatible
class DummyLink(CMSPlugin):
cmsplugin_ptr = models.OneToOneField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

coverage>=4.4.2
flake8>=3.0.4

-e git+ssh://git@github.com/divio/djangocms-transfer.git@master#egg=djangocms-transfer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm
this might be an issue on travis

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas here?

@coveralls
Copy link

coveralls commented Jan 11, 2018

Coverage Status

Coverage decreased (-0.7%) to 77.863% when pulling e513215 on bug/fix-context-translation2 into d758650 on master.

@coveralls
Copy link

coveralls commented Jan 11, 2018

Coverage Status

Coverage decreased (-0.7%) to 77.863% when pulling 01cd903 on bug/fix-context-translation2 into d758650 on master.



@unittest.skipUnless(
HAS_DJANGOCMS_TRANSLATIONS and HAS_DJANGOCMS_TRANSFER and X,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is X?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X is a stupid mistake. Shame on me. =P

@coveralls
Copy link

coveralls commented Jan 15, 2018

Coverage Status

Coverage decreased (-0.7%) to 77.863% when pulling b5cda86 on bug/fix-context-translation2 into d758650 on master.

@filwaitman filwaitman changed the title [WIP] Add context to translation payload when dealing with TextPlugin Add context to translation payload when dealing with TextPlugin Jan 15, 2018
@filwaitman filwaitman merged commit 126ee42 into master Jan 15, 2018
@filwaitman filwaitman deleted the bug/fix-context-translation2 branch January 15, 2018 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants