← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/fix-undiverging into lp:launchpad

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/fix-undiverging into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #716586 Diverged translation cannot be converged again.
  https://bugs.launchpad.net/bugs/716586

For more details, see:
https://code.launchpad.net/~abentley/launchpad/fix-undiverging/+merge/49718

= Summary =
Fix bug #716586: Diverged translation cannot be converged again.

== Proposed fix ==
Fix faulty check for whether the specified translation is already current for the template.

== Pre-implementation notes ==
None

== Implementation details ==
Instead of checking the is_current_ubuntu/is_current_upstream flags, which might be set for an existing shared translation, use getCurrentTranslation, which is the standard way to check whether a translation is current for a template.

== Tests ==
bin/test -v test_potmsgset -t approveExistingShared

== Demo and Q/A ==
Go to a translatable project, e.g. https://translations.qastaging.launchpad.net/mailclipper/trunk/+pots/testcase/fr/1/+translate.  Create a shared translation if none exists.  Create a diverged translation.  Change the diverged translation back to the shared translation (by selecting "In Ubuntu" or by manually specifyiing the same text).

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/translations/tests/test_potmsgset.py
  lib/lp/translations/model/potmsgset.py
-- 
https://code.launchpad.net/~abentley/launchpad/fix-undiverging/+merge/49718
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/fix-undiverging into lp:launchpad.
=== modified file 'lib/lp/translations/model/potmsgset.py'
--- lib/lp/translations/model/potmsgset.py	2011-02-04 17:14:20 +0000
+++ lib/lp/translations/model/potmsgset.py	2011-02-14 22:00:11 +0000
@@ -721,9 +721,9 @@
             that this change is based on.
         """
         template = pofile.potemplate
-        traits = getUtility(ITranslationSideTraitsSet).getTraits(
-            template.translation_side)
-        if traits.getFlag(suggestion):
+        current = self.getCurrentTranslation(
+            template, pofile.language, template.translation_side)
+        if current == suggestion:
             # Message is already current.
             return
 

=== modified file 'lib/lp/translations/tests/test_potmsgset.py'
--- lib/lp/translations/tests/test_potmsgset.py	2011-01-27 23:13:20 +0000
+++ lib/lp/translations/tests/test_potmsgset.py	2011-02-14 22:00:11 +0000
@@ -270,6 +270,20 @@
                 serbian, self.stable_potemplate.translation_side),
             shared_translation)
 
+    def test_approveExistingShared(self):
+        """"Existing shared translation become current when approved."""
+        pofile = self.factory.makePOFile()
+        shared = self.factory.makeCurrentTranslationMessage(pofile=pofile)
+        potmsgset = shared.potmsgset
+        diverged = self.factory.makeCurrentTranslationMessage(
+            pofile=pofile, potmsgset=potmsgset, diverged=True)
+        potemplate = diverged.potemplate
+        removeSecurityProxy(potmsgset).approveSuggestion(
+            pofile, shared, shared.reviewer)
+        current = potmsgset.getCurrentTranslation(
+            potemplate, pofile.language, potemplate.translation_side)
+        self.assertEqual(shared, current)
+
     def test_getLocalTranslationMessages(self):
         """Test retrieval of local suggestions."""
         # Share a POTMsgSet in two templates, and get a Serbian POFile.