← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:gdpr-add-translations-info into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:gdpr-add-translations-info into launchpad:master.

Commit message:
Add translations info to GDPR endpoint

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/406007
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:gdpr-add-translations-info into launchpad:master.
diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
index cb978a1..e0fbcd1 100644
--- a/lib/lp/registry/model/person.py
+++ b/lib/lp/registry/model/person.py
@@ -334,6 +334,7 @@ from lp.soyuz.model.archive import (
 from lp.soyuz.model.publishing import SourcePackagePublishingHistory
 from lp.soyuz.model.reporting import LatestPersonSourcePackageReleaseCache
 from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
+from lp.translations.interfaces.translationsperson import ITranslationsPerson
 from lp.translations.model.hastranslationimports import (
     HasTranslationImportsMixin,
     )
@@ -4112,6 +4113,10 @@ class PersonSet:
         blueprints_url = self._checkForBlueprints(account)
         if blueprints_url:
             return_data["blueprints"] = blueprints_url
+        # translations
+        translations_url = self._checkForTranslations(account)
+        if translations_url:
+            return_data["translations"] = translations_url
         # This is only an 'account' in terms of the end user view,
         # it does not refer to an `IAccount`.
         if len(return_data.keys()) > 1:
@@ -4182,6 +4187,16 @@ class PersonSet:
             return None
         return canonical_url(account, rootsite="blueprints")
 
+    def _checkForTranslations(self, account):
+        """Check for translation activity for a given user"""
+        translation_person = ITranslationsPerson(account)
+        # Has performed translations
+        if translation_person.hasTranslated():
+            return canonical_url(
+                account, rootsite="translations",
+                view_name="+activity")
+        return None
+
     def getUserOverview(self, person):
         """See `IPersonSet`."""
         overview = {}
diff --git a/lib/lp/registry/tests/test_personset.py b/lib/lp/registry/tests/test_personset.py
index 304074e..fce9148 100644
--- a/lib/lp/registry/tests/test_personset.py
+++ b/lib/lp/registry/tests/test_personset.py
@@ -12,6 +12,8 @@ from testtools.matchers import (
     Equals,
     GreaterThan,
     LessThan,
+    MatchesDict,
+    MatchesListwise,
     )
 import transaction
 from zope.component import getUtility
@@ -1301,6 +1303,21 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
             "blueprints": canonical_url(person, rootsite="blueprints")
             }, result)
 
+    def test_account_data_translations(self):
+        person = self.factory.makePerson(email="test@xxxxxxxxxxx")
+        self.factory.makeSuggestion(translator=person)
+        self.factory.makeTranslator(person=person)
+        with admin_logged_in():
+            result = self.person_set.getUserData(u"test@xxxxxxxxxxx")
+        self.assertThat(result, MatchesDict({
+            "status": Equals("account with data"),
+            "person": Equals(canonical_url(person)),
+            "translations": Equals(
+                canonical_url(
+                    person,
+                    rootsite="translations",
+                    view_name="+activity"))}))
+
     def test_getUserOverview(self):
         ppa = self.factory.makeArchive(owner=self.user)