launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29082
[Merge] ~andrey-fedoseev/launchpad:translation-suggestions into launchpad:master
Andrey Fedoseev has proposed merging ~andrey-fedoseev/launchpad:translation-suggestions into launchpad:master.
Commit message:
Don't show rejected messages in the list of suggestions
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~andrey-fedoseev/launchpad/+git/launchpad/+merge/428992
If a there's a message from an external project that has been rejected
(a newer message is set as current), that message should not be displayed
in the list of external suggestions.
Non-rejected suggestions (created after the current message has been approved)
are still displayed.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~andrey-fedoseev/launchpad:translation-suggestions into launchpad:master.
diff --git a/lib/lp/translations/browser/tests/test_translationmessage_view.py b/lib/lp/translations/browser/tests/test_translationmessage_view.py
index eff116c..74bb435 100644
--- a/lib/lp/translations/browser/tests/test_translationmessage_view.py
+++ b/lib/lp/translations/browser/tests/test_translationmessage_view.py
@@ -26,6 +26,7 @@ from lp.translations.browser.translationmessage import (
revert_unselected_translations,
)
from lp.translations.enums import TranslationPermission
+from lp.translations.interfaces.potemplate import IPOTemplateSet
from lp.translations.interfaces.side import ITranslationSideTraitsSet
from lp.translations.interfaces.translations import TranslationConstants
from lp.translations.interfaces.translationsperson import ITranslationsPerson
@@ -42,8 +43,8 @@ class TestCurrentTranslationMessage_can_dismiss(TestCaseWithFactory):
yield now
now += timedelta(milliseconds=1)
- def setUp(self):
- super().setUp()
+ def setUp(self, *args, **kwargs):
+ super().setUp(*args, **kwargs)
self.owner = self.factory.makePerson()
self.potemplate = self.factory.makePOTemplate(owner=self.owner)
self.pofile = self.factory.makePOFile(potemplate=self.potemplate)
@@ -53,15 +54,15 @@ class TestCurrentTranslationMessage_can_dismiss(TestCaseWithFactory):
def _createView(self, message):
self.view = CurrentTranslationMessageView(
- message,
- LaunchpadTestRequest(),
- {},
- dict(enumerate(message.translations)),
- False,
- False,
- None,
- None,
- True,
+ current_translation_message=message,
+ request=LaunchpadTestRequest(),
+ plural_indices_to_store={},
+ translations=dict(enumerate(message.translations)),
+ force_suggestion=False,
+ force_diverge=False,
+ error=None,
+ second_lang_code=None,
+ form_is_writeable=True,
pofile=self.pofile,
can_edit=True,
)
@@ -222,6 +223,86 @@ class TestCurrentTranslationMessage_can_dismiss(TestCaseWithFactory):
self._assertConfirmEmptyPluralOther(True, False, False, False)
+class TestCurrentTranslationMessageView(TestCaseWithFactory):
+
+ layer = ZopelessDatabaseLayer
+
+ def setUp(self, *args, **kwargs):
+ super().setUp(*args, **kwargs)
+ self.owner = self.factory.makePerson()
+ self.potemplate = self.factory.makePOTemplate(owner=self.owner)
+ self.pofile = self.factory.makePOFile(potemplate=self.potemplate)
+ self.potmsgset = self.factory.makePOTMsgSet(
+ self.potemplate, singular="original message"
+ )
+
+ def test_externally_used_and_suggested_messages(self):
+ message = self.factory.makeCurrentTranslationMessage(
+ self.pofile,
+ self.potmsgset,
+ translator=self.owner,
+ )
+ external_potemplate = self.factory.makePOTemplate(owner=self.owner)
+ external_pofile = self.factory.makePOFile(
+ potemplate=external_potemplate, language=self.pofile.language
+ )
+ external_potmsgset = self.factory.makePOTMsgSet(
+ external_potemplate, singular="original message"
+ )
+ externally_used_message = self.factory.makeCurrentTranslationMessage(
+ external_pofile,
+ external_potmsgset,
+ translator=self.owner,
+ translations=["used message"],
+ )
+ externally_suggested_message = self.factory.makeSuggestion(
+ external_pofile,
+ external_potmsgset,
+ translator=self.owner,
+ translations=["suggested message"],
+ date_created=externally_used_message.date_reviewed
+ + timedelta(days=1),
+ )
+ externally_rejected_message = self.factory.makeSuggestion(
+ external_pofile,
+ external_potmsgset,
+ translator=self.owner,
+ translations=["rejected message"],
+ date_created=externally_used_message.date_reviewed
+ - timedelta(days=1),
+ )
+ getUtility(IPOTemplateSet).populateSuggestivePOTemplatesCache()
+ view = CurrentTranslationMessageView(
+ current_translation_message=message,
+ request=LaunchpadTestRequest(),
+ plural_indices_to_store={},
+ translations=dict(enumerate(message.translations)),
+ force_suggestion=False,
+ force_diverge=False,
+ error=None,
+ second_lang_code=None,
+ form_is_writeable=True,
+ pofile=self.pofile,
+ can_edit=True,
+ )
+ view.initialize()
+ externally_used_messages = {
+ s.translationmessage
+ for s in view.suggestion_blocks[0][1].submissions
+ }
+ externally_suggested_messages = {
+ s.translationmessage
+ for s in view.suggestion_blocks[0][2].submissions
+ }
+ self.assertIn(externally_used_message, externally_used_messages)
+ self.assertIn(
+ externally_suggested_message, externally_suggested_messages
+ )
+ self.assertNotIn(
+ externally_rejected_message, externally_suggested_messages
+ )
+
+
class TestResetTranslations(TestCaseWithFactory):
"""Test resetting of the current translation.
diff --git a/lib/lp/translations/browser/translationmessage.py b/lib/lp/translations/browser/translationmessage.py
index 9d4856b..79f898e 100644
--- a/lib/lp/translations/browser/translationmessage.py
+++ b/lib/lp/translations/browser/translationmessage.py
@@ -1419,7 +1419,7 @@ class CurrentTranslationMessageView(LaunchpadView):
(
m
for m in translations[language].suggested
- if m.browser_pofile
+ if m.browser_pofile and not m.isHidden(m.browser_pofile)
),
key=operator.attrgetter("date_created"),
reverse=True,