← 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 query string to GDPR answers link

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/406031
-- 
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 3938cfc..f9d911e 100644
--- a/lib/lp/registry/model/person.py
+++ b/lib/lp/registry/model/person.py
@@ -4210,7 +4210,19 @@ class PersonSet:
             status=QuestionStatus.items)
         if questions.is_empty():
             return None
-        return canonical_url(account, rootsite="answers")
+        req = PreparedRequest()
+        answers_url = canonical_url(
+            account, rootsite="answers", view_name="+questions")
+        query_arguments = {
+            "field.search_text": "",
+            "field.sort": "RELEVANCY",
+            "field.sort-empty-marker": "1",
+            "field.actions.search": "Search",
+            "field.status-empty-marker": "1",
+            "field.status": [x.token for x in QuestionStatus]
+        }
+        req.prepare_url(answers_url, query_arguments)
+        return req.url
 
     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 6565833..9c7d308 100644
--- a/lib/lp/registry/tests/test_personset.py
+++ b/lib/lp/registry/tests/test_personset.py
@@ -1323,11 +1323,12 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
         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)
+        self.assertThat(result, ContainsDict({
+            "status": Equals("account with data"),
+            "person": Equals(canonical_url(person)),
+            "answers": Contains(
+                canonical_url(
+                    person, rootsite="answers"))}))
 
     def test_account_data_questions_comments(self):
         person = self.factory.makePerson(email="test@xxxxxxxxxxx")
@@ -1335,11 +1336,12 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
         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)
+        self.assertThat(result, ContainsDict({
+            "status": Equals("account with data"),
+            "person": Equals(canonical_url(person)),
+            "answers": Contains(
+                canonical_url(
+                    person, rootsite="answers"))}))
 
     def test_account_data_questions_solved(self):
         person = self.factory.makePerson(email="test@xxxxxxxxxxx")
@@ -1347,11 +1349,12 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
         with admin_logged_in():
             question.setStatus(person, QuestionStatus.SOLVED, "solved!")
             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)
+        self.assertThat(result, ContainsDict({
+            "status": Equals("account with data"),
+            "person": Equals(canonical_url(person)),
+            "answers": Contains(
+                canonical_url(
+                    person, rootsite="answers"))}))
 
     def test_getUserOverview(self):
         ppa = self.factory.makeArchive(owner=self.user)