← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Commit message:
Add answers info to GDPR endpoint

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/406009
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:gdpr-add-answers-info into launchpad:master.
diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
index e0fbcd1..8fee20c 100644
--- a/lib/lp/registry/model/person.py
+++ b/lib/lp/registry/model/person.py
@@ -112,6 +112,7 @@ from zope.security.proxy import (
     )
 
 from lp import _
+from lp.answers.interfaces.questionsperson import IQuestionsPerson
 from lp.answers.model.questionsperson import QuestionsPersonMixin
 from lp.app.enums import PRIVATE_INFORMATION_TYPES
 from lp.app.interfaces.launchpad import (
@@ -4113,10 +4114,17 @@ class PersonSet:
         blueprints_url = self._checkForBlueprints(account)
         if blueprints_url:
             return_data["blueprints"] = blueprints_url
+<<<<<<< lib/lp/registry/model/person.py
         # translations
         translations_url = self._checkForTranslations(account)
         if translations_url:
             return_data["translations"] = translations_url
+=======
+        # questions
+        questions_url = self._checkForAnswers(account)
+        if questions_url:
+            return_data["answers"] = questions_url
+>>>>>>> lib/lp/registry/model/person.py
         # 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:
@@ -4181,12 +4189,13 @@ class PersonSet:
         return req.url
 
     def _checkForBlueprints(self, account):
-        """check if related blueprints exist for a given person"""
+        """Check if related blueprints exist for a given person"""
         specifications = account.specifications(account)
         if specifications.is_empty():
             return None
         return canonical_url(account, rootsite="blueprints")
 
+<<<<<<< lib/lp/registry/model/person.py
     def _checkForTranslations(self, account):
         """Check for translation activity for a given user"""
         translation_person = ITranslationsPerson(account)
@@ -4196,6 +4205,14 @@ class PersonSet:
                 account, rootsite="translations",
                 view_name="+activity")
         return None
+=======
+    def _checkForAnswers(self, account):
+        """Check if related questions and answers exist for a given person."""
+        question_person = IQuestionsPerson(account)
+        if question_person.searchQuestions().is_empty():
+            return None
+        return canonical_url(account, rootsite="answers")
+>>>>>>> lib/lp/registry/model/person.py
 
     def getUserOverview(self, person):
         """See `IPersonSet`."""
diff --git a/lib/lp/registry/tests/test_personset.py b/lib/lp/registry/tests/test_personset.py
index bf8b21d..ce45a22 100644
--- a/lib/lp/registry/tests/test_personset.py
+++ b/lib/lp/registry/tests/test_personset.py
@@ -1302,6 +1302,7 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
             "blueprints": canonical_url(person, rootsite="blueprints")
             }, result)
 
+<<<<<<< lib/lp/registry/tests/test_personset.py
     def test_account_data_translations(self):
         person = self.factory.makePerson(email="test@xxxxxxxxxxx")
         self.factory.makeSuggestion(translator=person)
@@ -1316,6 +1317,30 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
                     person,
                     rootsite="translations",
                     view_name="+activity"))}))
+=======
+    def test_account_data_questions(self):
+        person = self.factory.makePerson(email="test@xxxxxxxxxxx")
+        self.factory.makeQuestion(owner=person)
+        with admin_logged_in():
+            result = self.person_set.getUserData(u"test@xxxxxxxxxxx")
+        self.assertDictEqual({
+            "status": "account with data",
+            "person": canonical_url(person),
+            "answers": canonical_url(person, rootsite="answers")
+            }, result)
+
+    def test_account_data_questions_comments(self):
+        person = self.factory.makePerson(email="test@xxxxxxxxxxx")
+        question = self.factory.makeQuestion(owner=self.factory.makePerson())
+        with admin_logged_in():
+            question.addComment(person, "A comment")
+            result = self.person_set.getUserData(u"test@xxxxxxxxxxx")
+        self.assertDictEqual({
+            "status": "account with data",
+            "person": canonical_url(person),
+            "answers": canonical_url(person, rootsite="answers")
+            }, result)
+>>>>>>> lib/lp/registry/tests/test_personset.py
 
     def test_getUserOverview(self):
         ppa = self.factory.makeArchive(owner=self.user)