← Back to team overview

launchpad-reviewers team mailing list archive

lp:~jcsackett/launchpad/project-involvement-translations-contradiction-652287 into lp:launchpad/devel

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/project-involvement-translations-contradiction-652287 into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #652287 project group translations page contradicts involvement portlet
  https://bugs.launchpad.net/bugs/652287


Summary
=======

Updates the involvement menu for translations on project groups to reflect the
status of translatable products within the project.

Proposed fix
============

Update project groups involvement menu to include the translatable products
conditions.

Pre-implementation notes
========================

Spoke with Curtis about the intent. Spoke with Danilos about what "translatable"
means in this context.

Implementation details
======================

Largely as in proposed; translations_usage on the projectgroup view is
overridden to UNKNOWN in the instance that no products are in the project
group's 'translatables' list.

Tests
=====

bin/test -t pillar-views

Demo and Q/A
============

On launchpad.dev/mozilla/+translations, the "Help translate" menu item is
no longer enabled. If you set up one of the mozilla products for translations,
it will become enabled.

Lint
====

make lint output:


= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/browser/pillar.py
  lib/lp/registry/browser/tests/pillar-views.txt
  lib/lp/registry/interfaces/projectgroup.py
  lib/lp/registry/model/projectgroup.py

./lib/lp/registry/model/projectgroup.py
     321: undefined name 'OfficialBugTag'

I'm not sure what's up with the OfficialBugTag issue. It occurs in storm query and isn't part of my branch. I'm happy to fix it, if it's something that needs fixing, but I wasn't sure of what's expected there.

-- 
https://code.launchpad.net/~jcsackett/launchpad/project-involvement-translations-contradiction-652287/+merge/37763
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/project-involvement-translations-contradiction-652287 into lp:launchpad/devel.
=== modified file 'lib/lp/registry/browser/pillar.py'
--- lib/lp/registry/browser/pillar.py	2010-09-28 20:57:34 +0000
+++ lib/lp/registry/browser/pillar.py	2010-10-06 17:01:08 +0000
@@ -119,6 +119,10 @@
             # Project groups do not support submit code, override the
             # default.
             self.codehosting_usage = ServiceUsage.NOT_APPLICABLE
+            # Product groups must have translatable products for
+            # translations_usage to be ServiceUsage.LAUNCHPAD
+            if not pillar.has_translatables():
+                self.translations_usage = ServiceUsage.UNKNOWN
         else:
             self._set_official_launchpad(pillar)
             if IDistroSeries.providedBy(self.context):

=== modified file 'lib/lp/registry/browser/tests/pillar-views.txt'
--- lib/lp/registry/browser/tests/pillar-views.txt	2010-09-28 20:57:34 +0000
+++ lib/lp/registry/browser/tests/pillar-views.txt	2010-10-06 17:01:08 +0000
@@ -200,6 +200,31 @@
     >>> print view.codehosting_usage.name
     NOT_APPLICABLE
 
+Project groups ignore products translations_usage setting if none of the
+products are fully configured as translatable.
+
+    >>> product.translations_usage = ServiceUsage.LAUNCHPAD
+    >>> project_group.has_translatables()
+    False
+
+    >>> view = create_view(project_group, '+get-involved')
+    >>> print view.translations_usage.name
+    UNKNOWN
+
+If a product is translatable, translations is enabled in the involvment menu.
+
+    >>> series = factory.makeProductSeries(product=product)
+    >>> pot = factory.makePOTemplateAndPOFiles(
+    ...     productseries=series,
+    ...     language_codes=['es'])
+    >>> product.translations_usage = ServiceUsage.LAUNCHPAD
+    >>> project_group.has_translatables()
+    True
+
+    >>> view = create_view(project_group, '+get-involved')
+    >>> print view.translations_usage.name
+    LAUNCHPAD
+
 DistroSeries can use this view. The distribution is used to set the links.
 
     >>> series = factory.makeDistroRelease(distribution=distribution)

=== modified file 'lib/lp/registry/interfaces/projectgroup.py'
--- lib/lp/registry/interfaces/projectgroup.py	2010-09-22 08:48:24 +0000
+++ lib/lp/registry/interfaces/projectgroup.py	2010-10-06 17:01:08 +0000
@@ -320,6 +320,10 @@
         It also should have IProduct.official_rosetta flag set.
         """
 
+    def has_translatables():
+        """Return a boolean showing the existance of translatables products.
+        """
+
     def hasProducts():
         """Returns True if a project has products associated with it, False
         otherwise.

=== modified file 'lib/lp/registry/model/projectgroup.py'
--- lib/lp/registry/model/projectgroup.py	2010-09-22 20:56:52 +0000
+++ lib/lp/registry/model/projectgroup.py	2010-10-06 17:01:08 +0000
@@ -216,6 +216,10 @@
             clauseTables=['ProductSeries', 'POTemplate'],
             distinct=True)
 
+    def has_translatables(self):
+        """See `IProjectGroup`."""
+        return self.translatables().count() != 0
+
     def _getBaseQueryAndClauseTablesForQueryingSprints(self):
         query = """
             Product.project = %s