Skip to content

Commit

Permalink
fixup! fix: avoid overriding manual edits for newer entries
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarIthawi committed Nov 9, 2023
1 parent cf96996 commit 9d41f4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/sync_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ def sync_translations(self, language_code, old_resource, new_resource):
if old_attr_value != getattr(new_translation, attr, None):
updates[attr] = old_attr_value

# Avoid overwriting more recent translations in the open-edx/openedx-translations project
newer_translation_found = False
if translation_from_old_project.datetime_translated and new_translation.datetime_translated:
old_project_translation_time = datetime.fromisoformat(
translation_from_old_project.datetime_translated.replace('Z', '+00:00'))
new_project_translation_time = datetime.fromisoformat(
new_translation.datetime_translated.replace('Z', '+00:00'))

if new_project_translation_time > old_project_translation_time:
newer_translation_found = True
newer_translation_found = new_project_translation_time > old_project_translation_time

if updates:
if newer_translation_found:
Expand Down
7 changes: 7 additions & 0 deletions scripts/tests/test_sync_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,10 @@ def test_get_translations():
items = list(data)
assert len(items) == 1
assert items[0].id == response_data.RESPONSE_GET_LANGUAGE['data'][0]['id']


@responses.activate
def test_more_recent_translations_not_overridden():
"""
Verify that the more recent translations in the open-edx/openedx-translations project are not overridden.
"""

0 comments on commit 9d41f4b

Please sign in to comment.