← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~salgado/launchpad/remove-translatablemessage into lp:launchpad

 

Guilherme Salgado has proposed merging lp:~salgado/launchpad/remove-translatablemessage into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~salgado/launchpad/remove-translatablemessage/+merge/93301

This removes TranslatableMessage, which was never used anywhere. This is not removing any pages, exported APIs nor breaking any tests, so I'm pretty sure we're not going to lose any functionality.
-- 
https://code.launchpad.net/~salgado/launchpad/remove-translatablemessage/+merge/93301
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~salgado/launchpad/remove-translatablemessage into lp:launchpad.
=== modified file 'lib/lp/translations/browser/pofile.py'
--- lib/lp/translations/browser/pofile.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/browser/pofile.py	2012-02-15 21:27:19 +0000
@@ -245,7 +245,7 @@
 
     @property
     def documentation_link_bubble(self):
-        """Reference to documentation, if appopriate."""
+        """Reference to documentation, if appropriate."""
         if not self.has_any_documentation:
             return ""
 
@@ -268,200 +268,6 @@
                 self.introduction_link, self.guide_links])
 
 
-class POFileBaseView(LaunchpadView, POFileMetadataViewMixin):
-    """A basic view for a POFile
-
-    This view is different from POFileView as it is the base for a new
-    generation of POFile views that use the new TranslatableMessage class
-    to display messages. They will eventually replace POFileView and its
-    decendants."""
-
-    DEFAULT_SHOW = 'all'
-    DEFAULT_SIZE = 10
-
-    def initialize(self):
-        super(POFileBaseView, self).initialize()
-
-        self._initializeShowOption()
-
-        self.batchnav = self._buildBatchNavigator()
-
-    @cachedproperty
-    def contributors(self):
-        return tuple(self.context.contributors)
-
-    @cachedproperty
-    def user_can_edit(self):
-        """Does the user have full edit rights for this translation?"""
-        return self.context.canEditTranslations(self.user)
-
-    @cachedproperty
-    def user_can_suggest(self):
-        """Is the user allowed to make suggestions here?"""
-        return self.context.canAddSuggestions(self.user)
-
-    @property
-    def permission_statement(self):
-        """Construct the statement about permissions.
-
-        Explain the permissions the current user has on this pofile.
-        """
-
-        if self.user_can_edit:
-            return _("You have full access to this translation.")
-        if self.user_can_suggest:
-            return _("Your suggestions will be held for review by "
-                     "the managers of this translation.")
-        # Check for logged in state
-        if self.user is None:
-            return _("You are not logged in.  Please log in to "
-                     "work on translations.")
-        if not self.has_translationgroup:
-            return _("This translation is not open for changes.")
-        if self.is_managed:
-            return _("This template can be translated only by its managers.")
-        return _("There is nobody to manage translation into this particular "
-                 "language.  If you are interested in working on it, please "
-                 "contact the translation group.")
-
-    @property
-    def translation_groups_statement(self):
-        """List translation groups and translation teams for this translation.
-
-        Returns a HTML string that lists the translation groups and the
-        relevant translators for this translation.
-        """
-        if self.translation_group is not None:
-            language = self.context.language
-            groups = []
-            for group in self.context.potemplate.translationgroups:
-                translator = group.query_translator(language)
-                # XXX: henninge 2009-09-09 bug=426745:
-                # The group and translator should be linkified.
-                if translator is None:
-                    groups.append(_(u"%s translation group") % group.title)
-                else:
-                    groups.append(_(u"%s assigned by %s") % (
-                        translator.translator.displayname, group.title))
-
-            # There are at most two translation groups, so just using 'and'
-            # is fine here.
-            statement = _(u"This translation is managed by %s.") % (
-                u" and ".join(groups))
-        else:
-            statement = _(u"No translation group has been assigned.")
-        return statement
-
-    @property
-    def number_of_plural_forms(self):
-        """The number of plural forms for the language or 1 if not known."""
-        if self.context.language.pluralforms is not None:
-            return self.context.language.pluralforms
-        return 1
-
-    @property
-    def plural_expression(self):
-        """The plural expression for this language or the empty string."""
-        if self.context.language.pluralexpression is not None:
-            return self.context.language.pluralexpression
-        return ""
-
-    def _initializeShowOption(self):
-        # Get any value given by the user
-        self.show = self.request.form_ng.getOne('show')
-        self.search_text = self.request.form_ng.getOne('search')
-        if self.search_text is not None:
-            self.show = 'all'
-
-        # Functions that deliver the correct message counts for each
-        # valid option value.
-        count_functions = {
-            'all': self.context.messageCount,
-            'translated': self.context.translatedCount,
-            'untranslated': self.context.untranslatedCount,
-            'new_suggestions': self.context.unreviewedCount,
-            'changed_in_ubuntu': self.context.updatesCount,
-            }
-
-        if self.show not in count_functions:
-            self.show = self.DEFAULT_SHOW
-
-        self.shown_count = count_functions[self.show]()
-
-    def _buildBatchNavigator(self):
-        """Construct a BatchNavigator of POTMsgSets and return it."""
-
-        # Changing the "show" option resets batching.
-        old_show_option = self.request.form_ng.getOne('old_show')
-        show_option_changed = (
-            old_show_option is not None and old_show_option != self.show)
-        if show_option_changed:
-            # Start will be 0 by default.
-            force_start = True
-        else:
-            force_start = False
-        return POFileBatchNavigator(self._getSelectedPOTMsgSets(),
-                                    self.request, size=self.DEFAULT_SIZE,
-                                    transient_parameters=["old_show"],
-                                    force_start=force_start)
-
-    def _handleShowAll(self):
-        """Get `POTMsgSet`s when filtering for "all" (but possibly searching).
-
-        Normally returns all `POTMsgSet`s for this `POFile`, but also handles
-        search requests which act as a separate form of filtering.
-        """
-        if self.search_text is None:
-            return self.context.potemplate.getPOTMsgSets()
-
-        if len(self.search_text) <= 1:
-            self.request.response.addWarningNotification(
-                "Please try searching for a longer string.")
-            return self.context.potemplate.getPOTMsgSets()
-
-        return self.context.findPOTMsgSetsContaining(text=self.search_text)
-
-    def _getSelectedPOTMsgSets(self):
-        """Return a list of the POTMsgSets that will be rendered."""
-        # The set of message sets we get is based on the selection of kind
-        # of strings we have in our form.
-        get_functions = {
-            'all': self._handleShowAll,
-            'translated': self.context.getPOTMsgSetTranslated,
-            'untranslated': self.context.getPOTMsgSetUntranslated,
-            'new_suggestions': self.context.getPOTMsgSetWithNewSuggestions,
-            'changed_in_ubuntu':
-                self.context.getPOTMsgSetDifferentTranslations,
-            }
-
-        if self.show not in get_functions:
-            raise UnexpectedFormData('show = "%s"' % self.show)
-
-        # We cannot listify the results to avoid additional count queries,
-        # because we could end up with a list of more than 32000 items with
-        # an average list of 5000 items.
-        # The batch system will slice the list of items so we will fetch only
-        # the exact number of entries we need to render the page.
-        return get_functions[self.show]()
-
-    @property
-    def messages(self):
-        """The list of TranslatableMessages to show."""
-        last = None
-        messages = []
-        for potmsgset in self.batchnav.currentBatch():
-            assert (last is None or
-                    potmsgset.getSequence(
-                        self.context.potemplate) >= last.getSequence(
-                            self.context.potemplate)), (
-                "POTMsgSets on page not in ascending sequence order")
-            last = potmsgset
-
-            messages.append(
-                self.context.makeTranslatableMessage(potmsgset))
-        return messages
-
-
 class POFileView(LaunchpadView):
     """A basic view for a POFile"""
 

=== removed file 'lib/lp/translations/browser/tests/pofile-base-views.txt'
--- lib/lp/translations/browser/tests/pofile-base-views.txt	2011-12-24 17:49:30 +0000
+++ lib/lp/translations/browser/tests/pofile-base-views.txt	1970-01-01 00:00:00 +0000
@@ -1,117 +0,0 @@
-POFileBaseView
-==============
-
-POFileBaseView provides different basic information about a POFile and a list
-of its content as TranslatableMessage objects.
-
-    >>> from lp.services.webapp.servers import LaunchpadTestRequest
-    >>> from lp.translations.browser.pofile import POFileBaseView
-
-    >>> potemplate = factory.makePOTemplate()
-    >>> pofile = factory.makePOFile('eo', potemplate)
-
-    >>> view = POFileBaseView(pofile, LaunchpadTestRequest())
-    >>> view.initialize()
-
-The view provides a statement to be displayed to the user about the
-permissions the user has on the POFile. When not logged in, the user cannot
-work on translations.
-
-    >>> print view.permission_statement
-    You are not logged in.  Please log in to work on translations.
-
-So we'd better log in.
-
-    >>> login('foo.bar@xxxxxxxxxxxxx')
-    >>> view = POFileBaseView(pofile, LaunchpadTestRequest())
-    >>> view.initialize()
-    >>> print view.permission_statement
-    You have full access to this translation.
-
-The view also provides more detailed information about what the user can do.
-
-    >>> print view.user_can_edit
-    True
-    >>> print view.user_can_suggest
-    True
-
-The view has information about the languages plural forms:
-
-    >>> print view.number_of_plural_forms
-    2
-    >>> print view.plural_expression
-    n != 1
-
-The view also know about the contributers to the translations in this POFile
-but currently there have not been any contributions yet.
-
-    >>> print view.contributors
-    ()
-
-So let's make a contribution.
-
-    >>> contributor = factory.makePerson(displayname="Contri Butor")
-    >>> potmsgset = factory.makePOTMsgSet(potemplate, sequence=1)
-    >>> translation = factory.makeCurrentTranslationMessage(pofile, potmsgset,
-    ...     translator=contributor, reviewer=contributor,
-    ...     translations=['A translation made by a contributor.'])
-    >>> view = POFileBaseView(pofile, LaunchpadTestRequest())
-    >>> view.initialize()
-    >>> print view.contributors[0].displayname
-    Contri Butor
-
-The view has a list of all translations.
-
-    >>> print view.messages[0].getCurrentTranslation().msgstr0.translation
-    A translation made by a contributor.
-
-The view can also tell us about the translation group but the pofile is not
-yet managed by a translation group.
-
-    >>> print view.translation_group
-    None
-
-The view makes a nice statement about this fact, too.
-
-    >>> print view.translation_groups_statement
-    No translation group has been assigned.
-
-So let's create one and let it manage the translations.
-
-    >>> group = factory.makeTranslationGroup(title="Test Translators")
-    >>> potemplate.product.translationgroup = group
-    >>> view = POFileBaseView(pofile, LaunchpadTestRequest())
-    >>> view.initialize()
-    >>> print view.translation_group.title
-    Test Translators
-
-Who is assigned to do translations into this language? Nobody so far.
-
-    >>> print view.translator
-    None
-
-Let's change that. A single person can be a tanslator
-
-    >>> translator = factory.makeTranslator('eo', group, contributor)
-    >>> view = POFileBaseView(pofile, LaunchpadTestRequest())
-    >>> view.initialize()
-    >>> print view.translator.displayname
-    Contri Butor
-
-See what statement the view makes now.
-
-    >>> print view.translation_groups_statement
-    This translation is managed by Contri Butor assigned by Test Translators.
-
-Neither the group nor the translator have managed to setup some documentation.
-
-    >>> view.has_any_documentation
-    False
-
-But now the group finally got around to it.
-
-    >>> group.translation_guide_url = "https://launchpad.net/";
-    >>> view = POFileBaseView(pofile, LaunchpadTestRequest())
-    >>> view.initialize()
-    >>> view.has_any_documentation
-    True

=== modified file 'lib/lp/translations/browser/tests/test_pofile_view.py'
--- lib/lp/translations/browser/tests/test_pofile_view.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/browser/tests/test_pofile_view.py	2012-02-15 21:27:19 +0000
@@ -3,13 +3,6 @@
 
 __metaclass__ = type
 
-from datetime import (
-    datetime,
-    timedelta,
-    )
-
-import pytz
-
 from lp.app.errors import UnexpectedFormData
 from lp.services.webapp.servers import LaunchpadTestRequest
 from lp.testing import (
@@ -22,135 +15,24 @@
     DatabaseFunctionalLayer,
     ZopelessDatabaseLayer,
     )
-from lp.translations.browser.pofile import (
-    POFileBaseView,
-    POFileTranslateView,
-    )
+from lp.translations.browser.pofile import POFileTranslateView
 from lp.translations.enums import TranslationPermission
 
 
-class TestPOFileBaseViewFiltering(TestCaseWithFactory):
-    """Test POFileBaseView filtering functions."""
-
-    layer = ZopelessDatabaseLayer
-
-    def gen_now(self):
-        now = datetime.now(pytz.UTC)
-        while True:
-            yield now
-            now += timedelta(milliseconds=1)
-
-    def setUp(self):
-        super(TestPOFileBaseViewFiltering, self).setUp()
-        self.now = self.gen_now().next
-        self.potemplate = self.factory.makePOTemplate()
-        self.pofile = self.factory.makePOFile('eo', self.potemplate)
-
-        # Create a number of POTMsgsets in different states.
-        # An untranslated message.
-        self.untranslated = self.factory.makePOTMsgSet(
-            self.potemplate, sequence=1)
-        # A translated message.
-        self.translated = self.factory.makePOTMsgSet(
-            self.potemplate, sequence=2)
-        self.factory.makeCurrentTranslationMessage(
-            self.pofile, self.translated)
-        # A translated message with a new suggestion.
-        self.new_suggestion = self.factory.makePOTMsgSet(
-            self.potemplate, sequence=3)
-        now = self.now()
-        self.factory.makeCurrentTranslationMessage(
-            pofile=self.pofile, potmsgset=self.new_suggestion,
-            date_created=now, date_reviewed=now)
-        now = self.now()
-        self.factory.makeSuggestion(
-            pofile=self.pofile, potmsgset=self.new_suggestion,
-            date_created=now)
-        # An upstream that was changed in Ubuntu.
-        self.changed = self.factory.makePOTMsgSet(self.potemplate, sequence=4)
-        now = self.now()
-        ubuntu_translation = self.factory.makeSuggestion(
-            pofile=self.pofile, potmsgset=self.changed, date_created=now)
-        ubuntu_translation.is_current_ubuntu = True
-        now = self.now()
-        self.factory.makeCurrentTranslationMessage(
-            pofile=self.pofile, potmsgset=self.changed, date_created=now,
-            date_reviewed=now)
-
-        # Update statistics so that shown_count returns correct values.
-        self.pofile.updateStatistics()
-
-    def _assertEqualPOTMsgSets(self, expected, messages):
-        self.assertEqual(expected, [tm.potmsgset for tm in messages])
-
-    def test_show_all_messages(self):
-        # The default is to show all messages.
-        view = POFileBaseView(self.pofile, LaunchpadTestRequest())
-        view.initialize()
-        self.assertEqual('all', view.DEFAULT_SHOW)
-        self.assertEqual(view.DEFAULT_SHOW, view.show)
-        self.assertEqual(4, view.shown_count)
-        self._assertEqualPOTMsgSets(
-            [self.untranslated, self.translated,
-             self.new_suggestion, self.changed],
-            view.messages)
-
-    def test_show_translated(self):
-        form = {'show': 'translated'}
-        view = POFileBaseView(self.pofile, LaunchpadTestRequest(form=form))
-        view.initialize()
-        self.assertEqual(3, view.shown_count)
-        self._assertEqualPOTMsgSets(
-            [self.translated, self.new_suggestion, self.changed],
-            view.messages)
-
-    def test_show_untranslated(self):
-        form = {'show': 'untranslated'}
-        view = POFileBaseView(self.pofile, LaunchpadTestRequest(form=form))
-        view.initialize()
-        self.assertEqual(1, view.shown_count)
-        self._assertEqualPOTMsgSets([self.untranslated], view.messages)
-
-    def test_show_new_suggestions(self):
-        form = {'show': 'new_suggestions'}
-        view = POFileBaseView(self.pofile, LaunchpadTestRequest(form=form))
-        view.initialize()
-        self.assertEqual(1, view.shown_count)
-        self._assertEqualPOTMsgSets([self.new_suggestion], view.messages)
-
-    def test_show_changed_in_ubuntu(self):
-        form = {'show': 'changed_in_ubuntu'}
-        view = POFileBaseView(self.pofile, LaunchpadTestRequest(form=form))
-        view.initialize()
-        self.assertEqual(1, view.shown_count)
-        self._assertEqualPOTMsgSets(
-             [self.changed], view.messages)
-
-    def test_show_invalid_filter(self):
-        # Invalid filter strings default to showing all messages.
-        form = {'show': 'foo_bar'}
-        view = POFileBaseView(self.pofile, LaunchpadTestRequest(form=form))
-        view.initialize()
-        self.assertEqual(view.DEFAULT_SHOW, view.show)
-        self._assertEqualPOTMsgSets(
-            [self.untranslated, self.translated,
-             self.new_suggestion, self.changed],
-            view.messages)
-
-
-class TestInvalidFilteringMixin:
+class TestPOFileTranslateViewInvalidFiltering(TestCaseWithFactory):
     """Test how POFile views reacts to malformed GET requests.
 
     Since any number of parameters can be entered throug the URL, the view
     should be robust about them and not produce OOPSes. This is achieved by
     raising UnexpectedFormData which is communicated to the user instead of
     being recorded as an OOPS.
-
-    POFileBaseView and POFileTranslateView implement this separately, so
-    two test cases are needed.
     """
+    layer = ZopelessDatabaseLayer
+    view_class = POFileTranslateView
 
-    view_class = None
+    def setUp(self):
+        super(TestPOFileTranslateViewInvalidFiltering, self).setUp()
+        self.pofile = self.factory.makePOFile('eo')
 
     def _test_parameter_list(self, parameter_name):
         # When a parameter is entered multiple times in an URL, it will be
@@ -170,33 +52,10 @@
         self._test_parameter_list('show')
 
 
-class TestPOFileBaseViewInvalidFiltering(TestCaseWithFactory,
-                                         TestInvalidFilteringMixin):
-    """Test for POFilleBaseView."""
-    layer = ZopelessDatabaseLayer
-    view_class = POFileBaseView
-
-    def setUp(self):
-        super(TestPOFileBaseViewInvalidFiltering, self).setUp()
-        self.pofile = self.factory.makePOFile('eo')
-
-
-class TestPOFileTranslateViewInvalidFiltering(TestCaseWithFactory,
-                                              TestInvalidFilteringMixin):
-    """Test for POFilleTranslateView."""
+class TestPOFileTranslateViewDocumentation(TestCaseWithFactory):
     layer = ZopelessDatabaseLayer
     view_class = POFileTranslateView
 
-    def setUp(self):
-        super(TestPOFileTranslateViewInvalidFiltering, self).setUp()
-        self.pofile = self.factory.makePOFile('eo')
-
-
-class DocumentationScenarioMixin:
-    """Tests for `POFileBaseView` and `POFileTranslateView`."""
-    # The view class that's being tested.
-    view_class = None
-
     def _makeLoggedInUser(self):
         """Create a user, and log in as that user."""
         email = self.factory.getUniqueString() + '@example.com'
@@ -431,18 +290,6 @@
         self.assertNotIn(language.englishname, view.documentation_link_bubble)
 
 
-class TestPOFileBaseViewDocumentation(TestCaseWithFactory,
-                                      DocumentationScenarioMixin):
-    layer = ZopelessDatabaseLayer
-    view_class = POFileBaseView
-
-
-class TestPOFileTranslateViewDocumentation(TestCaseWithFactory,
-                                           DocumentationScenarioMixin):
-    layer = ZopelessDatabaseLayer
-    view_class = POFileTranslateView
-
-
 class TestBrowser(BrowserTestCase):
 
     layer = DatabaseFunctionalLayer

=== removed file 'lib/lp/translations/browser/tests/test_translatablemessage_view.py'
--- lib/lp/translations/browser/tests/test_translatablemessage_view.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/browser/tests/test_translatablemessage_view.py	1970-01-01 00:00:00 +0000
@@ -1,97 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-__metaclass__ = type
-
-from lp.services.webapp.servers import LaunchpadTestRequest
-from lp.testing import TestCaseWithFactory
-from lp.testing.layers import LaunchpadZopelessLayer
-from lp.translations.browser.browser_helpers import text_to_html
-from lp.translations.browser.translatablemessage import (
-    TranslatableMessageView,
-    )
-from lp.translations.model.translatablemessage import TranslatableMessage
-
-
-class TestTranslatableMessageView(TestCaseWithFactory):
-    """Test ProductSeries view in translations facet."""
-
-    layer = LaunchpadZopelessLayer
-
-    def setUp(self):
-        # Create a POTMsgSet and a POFile to create a TranslatableMessage
-        # from. Create the view from the message.
-        super(TestTranslatableMessageView, self).setUp()
-        self.potemplate = self.factory.makePOTemplate()
-        self.potmsgset = self.factory.makePOTMsgSet(
-            self.potemplate, sequence=1, singular=u"English singular")
-        self.pofile = self.factory.makePOFile('eo', self.potemplate)
-        self.message = None
-
-    def _create_view(self):
-        self.message = TranslatableMessage(self.potmsgset, self.pofile)
-        return TranslatableMessageView(self.message,
-                                            LaunchpadTestRequest())
-
-    def test_empty_message(self):
-        # View information for an empty message.
-        view = self._create_view()
-        info = view.current_translation
-
-        self.assertEqual(None, info['translator'])
-        self.assertEqual(u'', info['translator_class'])
-        self.assertContentEqual(
-            [{'plural': u"", 'text': u"(no translation yet)"}],
-            info['translations'])
-        self.assertEqual(u'current_empty', info['translation_class'])
-
-    def test_singular_message(self):
-        # View information for a singular message.
-        translator = self.factory.makePerson()
-        self.factory.makeCurrentTranslationMessage(
-            self.pofile, self.potmsgset,
-            translations=[u'foo'], translator=translator)
-        view = self._create_view()
-        info = view.current_translation
-
-        self.assertEqual(u'English singular', view.singular_text)
-        self.assertEqual(translator, info['translator'])
-        self.assertEqual('translator_singular', info['translator_class'])
-        self.assertContentEqual(
-            [{'plural': u"", 'text': u"foo"}],
-            info['translations'])
-        self.assertEqual(u'current', info['translation_class'])
-
-    def test_plural_message(self):
-        # View information for a message with plural.
-        self.potmsgset.updatePluralForm(u'English plural')
-        translator = self.factory.makePerson()
-        self.factory.makeCurrentTranslationMessage(
-            self.pofile, self.potmsgset,
-            translations=[u'foo', u'bar'], translator=translator)
-        view = self._create_view()
-        info = view.current_translation
-
-        self.assertEqual(u'English plural', view.plural_text)
-        self.assertEqual(translator, info['translator'])
-        self.assertEqual('translator_plural', info['translator_class'])
-        self.assertContentEqual(
-            [{'plural': u"Plural 0:", 'text': u"foo"},
-             {'plural': u"Plural 1:", 'text': u"bar"}],
-            info['translations'])
-        self.assertEqual(u'current', info['translation_class'])
-
-    def test_browser_message(self):
-        # Special treatment on some characters for browser display.
-        TRANSLATION = u"foo \nbar"
-        translator = self.factory.makePerson()
-        self.potmsgset.updatePluralForm(u'English plural')
-        self.factory.makeCurrentTranslationMessage(
-            self.pofile, self.potmsgset,
-            translations=[TRANSLATION], translator=translator)
-        view = self._create_view()
-        info = view.current_translation
-
-        self.assertEqual(
-            text_to_html(TRANSLATION, self.potmsgset.flags),
-            info['translations'][0]['text'])

=== removed file 'lib/lp/translations/browser/translatablemessage.py'
--- lib/lp/translations/browser/translatablemessage.py	2011-12-24 17:49:30 +0000
+++ lib/lp/translations/browser/translatablemessage.py	1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Browser code for Product Series Languages."""
-
-__metaclass__ = type
-
-__all__ = ['TranslatableMessageView']
-
-from lp.services.webapp import LaunchpadView
-from lp.translations.browser.browser_helpers import text_to_html
-
-
-class TranslatableMessageView(LaunchpadView):
-    """View class to render an `ITranslatableMessage`."""
-
-    @property
-    def label(self):
-        """The form label."""
-        return 'Translate messge %d into %s' % (
-            self.context.sequence,
-            self.context.pofile.language.englishname)
-
-    @property
-    def page_title(self):
-        """The page title."""
-        return self.label
-
-    @property
-    def singular_text(self):
-        """HTML version of the singular msgid."""
-        return text_to_html(self.context.potmsgset.singular_text,
-                            self.context.potmsgset.flags)
-
-    @property
-    def plural_text(self):
-        """HTML version of the plural msgid."""
-        return text_to_html(self.context.potmsgset.plural_text,
-                            self.context.potmsgset.flags)
-
-    def _translation_info(self, plural, text):
-        """Build a dictionary with 'plural' and 'text' keys."""
-        return {'plural': plural,
-                'text': text_to_html(text, self.context.potmsgset.flags)}
-
-    def _make_translation_info(self, translationmessage):
-        """Prepare translation information for the given message."""
-        if self.context.has_plural_forms:
-            translations = [
-                self._translation_info(u"Plural %d:" % index, msgstr)
-                for index, msgstr in enumerate(
-                                        translationmessage.translations)]
-            translator_class = "translator_plural"
-        else:
-            translations = [self._translation_info(
-                                "", translationmessage.msgstr0.translation)]
-            translator_class = "translator_singular"
-        return {
-            'translator': translationmessage.submitter,
-            'translation_class': 'current',
-            'translator_class': translator_class,
-            'translations': translations,
-            }
-
-    @property
-    def current_translation(self):
-        """Information about the current translation prepared for display.
-
-        :returns: A dictionary with the following keys:
-          translator - The IPerson object of the translator or None.
-          translations - A list of dictionaries with the following keys:
-            plural - The plural label to explain this form or an empty string
-            text - The actual translation text as HTML
-          translator_class - the css class to use for the translator
-          translation_class - The css class to use for the translation
-        """
-        current = self.context.getCurrentTranslation()
-        if current is None:
-            return {'translator': None,
-                    'translation_class': 'current_empty',
-                    'translator_class': '',
-                    'translations': [
-                        self._translation_info(u"", u"(no translation yet)")]}
-        return self._make_translation_info(current)
-

=== modified file 'lib/lp/translations/configure.zcml'
--- lib/lp/translations/configure.zcml	2011-12-24 17:49:30 +0000
+++ lib/lp/translations/configure.zcml	2012-02-15 21:27:19 +0000
@@ -515,11 +515,6 @@
             permission="launchpad.Admin"
             set_attributes="commenttext sourcecomment filereferences flagscomment"/>
     </class>
-    <class
-        class="lp.translations.model.translatablemessage.TranslatableMessage">
-        <allow
-            interface="lp.translations.interfaces.translatablemessage.ITranslatableMessage"/>
-    </class>
 
         <!-- LanguagePack -->
 

=== modified file 'lib/lp/translations/interfaces/pofile.py'
--- lib/lp/translations/interfaces/pofile.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/interfaces/pofile.py	2012-02-15 21:27:19 +0000
@@ -210,12 +210,6 @@
         set down using the condition.
         """
 
-    def makeTranslatableMessage(potmsgset):
-        """Factory method for an `ITranslatableMessage` object.
-
-        :param potmsgset: The `IPOTMsgSet` to combine this pofile with.
-        """
-
     def export(ignore_obsolete=False, export_utf8=False):
         """Export this PO file as string.
 

=== removed file 'lib/lp/translations/interfaces/translatablemessage.py'
--- lib/lp/translations/interfaces/translatablemessage.py	2011-12-24 16:54:44 +0000
+++ lib/lp/translations/interfaces/translatablemessage.py	1970-01-01 00:00:00 +0000
@@ -1,115 +0,0 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-# pylint: disable-msg=E0211,E0213
-
-from zope.interface import (
-    Attribute,
-    Interface,
-    )
-from zope.schema import (
-    Bool,
-    Int,
-    )
-
-from lp import _
-
-
-__metaclass__ = type
-
-__all__ = [
-    'ITranslatableMessage',
-    ]
-
-class ITranslatableMessage(Interface):
-    """An IPOTMsgSet in the context of a certain IPOFile."""
-
-    pofile = Attribute("The IPOFile")
-    potmsgset = Attribute("The POTMsgset")
-
-    sequence = Int(
-        title=_("Sequence number within the POTemplate."),
-        required=True)
-
-    is_obsolete = Bool(
-        title=_("This TranslatableMessage is obsolete"),
-        required=True)
-
-    is_untranslated = Bool(
-        title=_("The current translation is empty"),
-        required=True)
-
-    is_current_diverged = Bool(
-        title=_("The current translation is diverged"),
-        required=True)
-
-    is_current_imported = Bool(
-        title=_("The current translation is used upstream"),
-        required=True)
-
-    has_plural_forms = Bool(
-        title=_("There is an English plural string"),
-        required=True)
-
-    number_of_plural_forms = Int(
-        title=_("Number of plural forms in the target language"),
-        required=True)
-
-    def getCurrentTranslation():
-        """Get the TranslationMessage that holds the current translation."""
-
-    def getImportedTranslation():
-        """Get the TranslationMessage that is marked as current-upstream.
-
-        This can be None if there is no such message, or it can be
-        identical to the current Ubuntu translation.
-        """
-
-    def getSharedTranslation():
-        """Get the TranslationMessage that is marked as shared.
-
-        This can be None if there is no such message or it can be identical
-        to the current translation if the current translation is shared.
-        """
-
-    def getAllSuggestions():
-        """Return an iterator over all suggested translations."""
-
-    def getUnreviewedSuggestions():
-        """Return an iterator over unreviewed suggested translations.
-
-        Return those translation messages that have a creation date newer
-        than the review date of the current message (have not been reviewed).
-        """
-
-    def getDismissedSuggestions(include_dismissed=True):
-        """Return an iterator over dismissed suggested translations.
-
-        Return those translation messages that have a creation date older
-        than the review date of the current message (have been dismissed).
-        """
-
-    def getExternalTranslations():
-        """Return an iterator over external translations.
-
-        External translations are translations for the same English string
-        in other products and source packages.
-        """
-
-    def getExternalSuggestions():
-        """Return an iterator over externally suggested translations.
-
-        External suggested translations are suggestions for the same English
-        string in other products and source packages.
-        """
-
-    def dismissAllSuggestions(reviewer, lock_timestamp):
-        """Dismiss all suggestions.
-
-        :param reviewer: the person that is doing the dismissal.
-        :param lock_timestamp: the timestamp when we checked the values we
-            want to update.
-
-        Raises TranslationConflict if two edits happen simultaneously.
-        """
-

=== modified file 'lib/lp/translations/model/pofile.py'
--- lib/lp/translations/model/pofile.py	2011-12-30 06:14:56 +0000
+++ lib/lp/translations/model/pofile.py	2012-02-15 21:27:19 +0000
@@ -102,7 +102,6 @@
     credits_message_str,
     POTMsgSet,
     )
-from lp.translations.model.translatablemessage import TranslatableMessage
 from lp.translations.model.translationimportqueue import collect_import_info
 from lp.translations.model.translationmessage import (
     make_plurals_sql_fragment,
@@ -329,10 +328,6 @@
         """See `IPOFile`."""
         return self.language.englishname
 
-    def makeTranslatableMessage(self, potmsgset):
-        """See `IPOFile`."""
-        return TranslatableMessage(potmsgset, self)
-
     def markChanged(self, translator=None, timestamp=None):
         """See `IPOFile`."""
         if timestamp is None:

=== removed file 'lib/lp/translations/model/translatablemessage.py'
--- lib/lp/translations/model/translatablemessage.py	2010-12-14 16:57:36 +0000
+++ lib/lp/translations/model/translatablemessage.py	1970-01-01 00:00:00 +0000
@@ -1,134 +0,0 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Implementation for `ITranslatableMessage`."""
-
-__metaclass__ = type
-
-__all__ = [
-    'TranslatableMessage',
-    ]
-
-from zope.interface import implements
-
-from lp.translations.interfaces.translatablemessage import (
-    ITranslatableMessage,
-    )
-
-
-class TranslatableMessage(object):
-    """See `ITranslatableMessage`."""
-    implements(ITranslatableMessage)
-
-    potmsgset = None
-    pofile = None
-    sequence = 0
-
-    def __init__(self, potmsgset, pofile):
-        """Create a new TranslatableMessage object.
-
-        :param potmsgset: The `IPOTMsgSet` instance that this object refers
-          to.
-        :param pofile: The `IPOFile` instance that the potmsgset is used
-          with.
-
-        Both potmsgset and pofile must be related, meaning they refer to the
-        same `IPOTemplate` instance.
-        """
-        assert pofile.potemplate.getPOTMsgSetByID(potmsgset.id) != None, (
-          "POTMsgSet and POFile must refer to the same POTemplate.")
-
-        self.potmsgset = potmsgset
-        self.pofile = pofile
-        self.sequence = potmsgset.getSequence(pofile.potemplate)
-        self.potemplate = pofile.potemplate
-        self.language = pofile.language
-
-        self._current_translation = self.potmsgset.getCurrentTranslation(
-            self.potemplate, self.language, self.potemplate.translation_side)
-
-    @property
-    def is_obsolete(self):
-        """See `ITranslatableMessage`"""
-        return self.sequence == 0
-
-    @property
-    def is_untranslated(self):
-        """See `ITranslatableMessage`"""
-        if self._current_translation is None:
-            return True
-        return self._current_translation.is_empty
-
-    @property
-    def is_current_diverged(self):
-        """See `ITranslatableMessage`"""
-        if self._current_translation is None:
-            return False
-        return self._current_translation.potemplate == self.potemplate
-
-    @property
-    def is_current_imported(self):
-        """See `ITranslatableMessage`"""
-        if self._current_translation is None:
-            return False
-        return self._current_translation.is_current_upstream
-
-    @property
-    def has_plural_forms(self):
-        """See `ITranslatableMessage`"""
-        return self.potmsgset.msgid_plural is not None
-
-    @property
-    def number_of_plural_forms(self):
-        """See `ITranslatableMessage`"""
-        if self.has_plural_forms:
-            return self.pofile.plural_forms
-        else:
-            return 1
-
-    def getCurrentTranslation(self):
-        """See `ITranslatableMessage`"""
-        return self._current_translation
-
-    def getImportedTranslation(self):
-        """See `ITranslatableMessage`"""
-        return self.potmsgset.getOtherTranslation(
-            self.language, self.potemplate.translation_side)
-
-    def getSharedTranslation(self):
-        """See `ITranslatableMessage`"""
-        return self.potmsgset.getSharedTranslation(
-            self.language, self.potemplate.translation_side)
-
-    def getAllSuggestions(self):
-        """See `ITranslatableMessage`"""
-        return self.potmsgset.getLocalTranslationMessages(
-            self.potemplate, self.language,
-            include_dismissed=True, include_unreviewed=True)
-
-    def getUnreviewedSuggestions(self):
-        """See `ITranslatableMessage`"""
-        return self.potmsgset.getLocalTranslationMessages(
-            self.potemplate, self.language,
-            include_dismissed=False, include_unreviewed=True)
-
-    def getDismissedSuggestions(self):
-        """See `ITranslatableMessage`"""
-        return self.potmsgset.getLocalTranslationMessages(
-            self.potemplate, self.language,
-            include_dismissed=True, include_unreviewed=False)
-
-    def getExternalTranslations(self):
-        """See `ITranslatableMessage`"""
-        lang = self.language
-        return self.potmsgset.getExternallyUsedTranslationMessages(lang)
-
-    def getExternalSuggestions(self):
-        """See `ITranslatableMessage`"""
-        lang = self.language
-        return self.potmsgset.getExternallySuggestedTranslationMessages(lang)
-
-    def dismissAllSuggestions(self, reviewer, lock_timestamp):
-        """See `ITranslatableMessage`"""
-        self.potmsgset.dismissAllSuggestions(
-            self.pofile, reviewer, lock_timestamp)

=== modified file 'lib/lp/translations/tests/test_pofile.py'
--- lib/lp/translations/tests/test_pofile.py	2011-12-30 06:14:56 +0000
+++ lib/lp/translations/tests/test_pofile.py	2012-02-15 21:27:19 +0000
@@ -14,7 +14,6 @@
     getAdapter,
     getUtility,
     )
-from zope.interface.verify import verifyObject
 from zope.security.proxy import removeSecurityProxy
 
 from lp.app.enums import ServiceUsage
@@ -26,9 +25,6 @@
 from lp.testing.layers import ZopelessDatabaseLayer
 from lp.translations.interfaces.pofile import IPOFileSet
 from lp.translations.interfaces.side import ITranslationSideTraitsSet
-from lp.translations.interfaces.translatablemessage import (
-    ITranslatableMessage,
-    )
 from lp.translations.interfaces.translationcommonformat import (
     ITranslationFileData,
     )
@@ -2038,12 +2034,6 @@
         self.pofile = self.factory.makePOFile('eo')
         self.potemplate = self.pofile.potemplate
 
-    def test_makeTranslatableMessage(self):
-        # TranslatableMessages can be created from the PO file
-        potmsgset = self.factory.makePOTMsgSet(self.potemplate)
-        message = self.pofile.makeTranslatableMessage(potmsgset)
-        verifyObject(ITranslatableMessage, message)
-
     def _createMessageSet(self, testmsg):
         # Create a message set from the test data.
         potmsgset = self.factory.makePOTMsgSet(

=== removed file 'lib/lp/translations/tests/test_translatablemessage.py'
--- lib/lp/translations/tests/test_translatablemessage.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/tests/test_translatablemessage.py	1970-01-01 00:00:00 +0000
@@ -1,229 +0,0 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
-# GNU Affero General Public License version 3 (see the file LICENSE).
-
-"""Unit tests for `TranslatableMessage`."""
-
-__metaclass__ = type
-
-from datetime import (
-    datetime,
-    timedelta,
-    )
-
-import pytz
-import transaction
-from zope.component import getUtility
-
-from lp.app.enums import ServiceUsage
-from lp.testing import TestCaseWithFactory
-from lp.testing.layers import ZopelessDatabaseLayer
-from lp.translations.interfaces.potemplate import IPOTemplateSet
-from lp.translations.model.translatablemessage import TranslatableMessage
-
-
-class TestTranslatableMessageBase:
-    """Common setup for `TranslatableMessage`."""
-
-    layer = ZopelessDatabaseLayer
-
-    def setUp(self):
-        """Create common objects for all tests.
-
-        Arranges for a `ProductSeries` with `POTemplate` and
-        `POTMsgSet`, as well as a Esperanto translation.
-        """
-        super(TestTranslatableMessageBase, self).setUp()
-        self.product = self.factory.makeProduct(
-            translations_usage=ServiceUsage.LAUNCHPAD)
-        self.trunk = self.product.getSeries('trunk')
-        self.potemplate = self.factory.makePOTemplate(
-            productseries=self.trunk)
-        self.potmsgset = self.factory.makePOTMsgSet(
-            potemplate=self.potemplate)
-        self.pofile = self.factory.makePOFile(
-            potemplate=self.potemplate, language_code='eo')
-
-    def _createTranslation(self, translation=None, is_current_ubuntu=False,
-                           is_current_upstream=False, is_diverged=False,
-                           date_updated=None):
-        if translation is not None:
-            translation = [translation]
-
-        if is_current_upstream:
-            message = self.factory.makeCurrentTranslationMessage(
-                pofile=self.pofile, potmsgset=self.potmsgset,
-                translations=translation,
-                current_other=is_current_ubuntu,
-                diverged=is_diverged,
-                date_created=date_updated,
-                date_reviewed=date_updated)
-        else:
-            message = self.factory.makeSuggestion(
-                pofile=self.pofile, potmsgset=self.potmsgset,
-                translations=translation, date_created=date_updated)
-            message.is_current_ubuntu = is_current_ubuntu
-            self.assertFalse(
-                is_diverged,
-                "Diverging message to a template it's not current in.")
-
-        return message
-
-
-class TestTranslatableMessage(TestTranslatableMessageBase,
-                              TestCaseWithFactory):
-    """Test of `TranslatableMessage` properties and methods."""
-
-    def test_sequence(self):
-        # After instantiation, the sequence number from the potmsgset is
-        # available.
-        self.potmsgset.setSequence(self.potemplate, 1)
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        self.assertEqual(1, message.sequence)
-
-    def test_is_obsolete(self):
-        # A message is obsolete if the sequence number is 0.
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        self.assertFalse(message.is_obsolete)
-
-        self.potmsgset.setSequence(self.potemplate, 0)
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        self.assertTrue(message.is_obsolete)
-
-    def test_is_untranslated(self):
-        translation = self._createTranslation('', is_current_ubuntu=True)
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        self.assertTrue(message.is_untranslated)
-
-    def test_is_current_diverged(self):
-        translation = self._createTranslation(
-            is_current_upstream=True, is_diverged=True)
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        self.assertTrue(message.is_current_diverged)
-
-    def test_is_current_imported(self):
-        translation = self._createTranslation(is_current_ubuntu=True,
-                                              is_current_upstream=True)
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        self.assertTrue(message.is_current_imported)
-
-    def test_has_plural_forms(self):
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        self.assertFalse(message.has_plural_forms)
-
-        self.potmsgset.updatePluralForm(u"fooplural")
-        self.assertTrue(message.has_plural_forms)
-
-    def test_number_of_plural_forms(self):
-        # eo has 2 plural forms, sr has 3
-        self.potmsgset.updatePluralForm(u"fooplural")
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        self.assertEqual(2, message.number_of_plural_forms)
-
-        sr_pofile = self.factory.makePOFile(
-            potemplate=self.potemplate, language_code='sr')
-        message = TranslatableMessage(self.potmsgset, sr_pofile)
-        self.assertEqual(3, message.number_of_plural_forms)
-
-    def test_getCurrentTranslation(self):
-        translation = self._createTranslation(is_current_upstream=True)
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        current = message.getCurrentTranslation()
-        self.assertEqual(translation, current)
-
-    def test_getImportedTranslation(self):
-        translation = self._createTranslation(is_current_ubuntu=True)
-
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        imported = message.getImportedTranslation()
-        self.assertEqual(translation, imported)
-
-    def test_getSharedTranslation(self):
-        translation = self._createTranslation(is_current_upstream=True)
-        message = TranslatableMessage(self.potmsgset, self.pofile)
-        shared = message.getSharedTranslation()
-        self.assertEqual(translation, shared)
-
-
-class TestTranslatableMessageExternal(TestTranslatableMessageBase,
-                                      TestCaseWithFactory):
-    """Test of `TranslatableMessage` methods for external translations."""
-
-    def setUp(self):
-        # Create a potmsgset with the same msg id in another product
-        super(TestTranslatableMessageExternal, self).setUp()
-        common_msgid = self.potmsgset.singular_text
-        self.external_potemplate = self.factory.makePOTemplate()
-        product = self.external_potemplate.productseries.product
-        product.translations_usage = ServiceUsage.LAUNCHPAD
-        self.external_potmsgset = self.factory.makePOTMsgSet(
-            potemplate=self.external_potemplate,
-            singular=common_msgid)
-        self.external_pofile = self.factory.makePOFile(
-            potemplate=self.external_potemplate, language_code='eo')
-
-        self.external_suggestion = self.factory.makeCurrentTranslationMessage(
-            pofile=self.external_pofile, potmsgset=self.external_potmsgset)
-        self.external_current = self.factory.makeCurrentTranslationMessage(
-            pofile=self.external_pofile, potmsgset=self.external_potmsgset)
-
-        self.message = TranslatableMessage(self.potmsgset, self.pofile)
-
-        self._refreshSuggestiveTemplatesCache()
-
-    def _refreshSuggestiveTemplatesCache(self):
-        """Refresh the `SuggestivePOTemplate` cache."""
-        getUtility(IPOTemplateSet).populateSuggestivePOTemplatesCache()
-
-    def test_getExternalTranslations(self):
-        transaction.commit()
-        externals = self.message.getExternalTranslations()
-        self.assertContentEqual([self.external_current], externals)
-
-    def test_getExternalSuggestions(self):
-        transaction.commit()
-        externals = self.message.getExternalSuggestions()
-        self.assertContentEqual([self.external_suggestion], externals)
-
-
-class TestTranslatableMessageSuggestions(TestTranslatableMessageBase,
-                                         TestCaseWithFactory):
-    """Test of `TranslatableMessage` methods for getting suggestions."""
-
-    def gen_now(self):
-        now = datetime.now(pytz.UTC)
-        while True:
-            yield now
-            now += timedelta(milliseconds=1)
-
-    def setUp(self):
-        super(TestTranslatableMessageSuggestions, self).setUp()
-        self.now = self.gen_now().next
-        self.suggestion1 = self._createTranslation(date_updated=self.now())
-        self.current = self._createTranslation(
-            is_current_upstream=True, date_updated=self.now())
-        self.suggestion2 = self._createTranslation(date_updated=self.now())
-        self.message = TranslatableMessage(self.potmsgset, self.pofile)
-
-    def test_getAllSuggestions(self):
-        # There are three different methods to return.
-        suggestions = self.message.getAllSuggestions()
-        self.assertContentEqual(
-            [self.suggestion1, self.suggestion2], suggestions)
-
-    def test_getDismissedSuggestions(self):
-        # There are three different methods to return.
-        suggestions = self.message.getDismissedSuggestions()
-        self.assertContentEqual([self.suggestion1], suggestions)
-
-    def test_getUnreviewedSuggestions(self):
-        # There are three different methods to return.
-        suggestions = self.message.getUnreviewedSuggestions()
-        self.assertContentEqual([self.suggestion2], suggestions)
-
-    def test_dismissAllSuggestions(self):
-        # Add a suggestion that is newer than the current translation and
-        # dismiss it. Also show that getSuggestions only returns translations
-        # that are newer than the current one unless only_new is set to False.
-        self.message.dismissAllSuggestions(self.potemplate.owner, self.now())
-        suggestions = self.message.getUnreviewedSuggestions()
-        self.assertContentEqual([], suggestions)