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

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 627b4c0726f9d202602a268a5c60304ad66446f9
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:gdpr-add-answers-info
Merge into: launchpad:master
Diff against target: 83 lines (+31/-16)
2 files modified
lib/lp/registry/model/person.py (+13/-1)
lib/lp/registry/tests/test_personset.py (+18/-15)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+406031@code.launchpad.net

Commit message

Add query string to GDPR answers link

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
2index 3938cfc..f9d911e 100644
3--- a/lib/lp/registry/model/person.py
4+++ b/lib/lp/registry/model/person.py
5@@ -4210,7 +4210,19 @@ class PersonSet:
6 status=QuestionStatus.items)
7 if questions.is_empty():
8 return None
9- return canonical_url(account, rootsite="answers")
10+ req = PreparedRequest()
11+ answers_url = canonical_url(
12+ account, rootsite="answers", view_name="+questions")
13+ query_arguments = {
14+ "field.search_text": "",
15+ "field.sort": "RELEVANCY",
16+ "field.sort-empty-marker": "1",
17+ "field.actions.search": "Search",
18+ "field.status-empty-marker": "1",
19+ "field.status": [x.token for x in QuestionStatus]
20+ }
21+ req.prepare_url(answers_url, query_arguments)
22+ return req.url
23
24 def getUserOverview(self, person):
25 """See `IPersonSet`."""
26diff --git a/lib/lp/registry/tests/test_personset.py b/lib/lp/registry/tests/test_personset.py
27index 6565833..9c7d308 100644
28--- a/lib/lp/registry/tests/test_personset.py
29+++ b/lib/lp/registry/tests/test_personset.py
30@@ -1323,11 +1323,12 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
31 self.factory.makeQuestion(owner=person)
32 with admin_logged_in():
33 result = self.person_set.getUserData(u"test@example.com")
34- self.assertDictEqual({
35- "status": "account with data",
36- "person": canonical_url(person),
37- "answers": canonical_url(person, rootsite="answers")
38- }, result)
39+ self.assertThat(result, ContainsDict({
40+ "status": Equals("account with data"),
41+ "person": Equals(canonical_url(person)),
42+ "answers": Contains(
43+ canonical_url(
44+ person, rootsite="answers"))}))
45
46 def test_account_data_questions_comments(self):
47 person = self.factory.makePerson(email="test@example.com")
48@@ -1335,11 +1336,12 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
49 with admin_logged_in():
50 question.addComment(person, "A comment")
51 result = self.person_set.getUserData(u"test@example.com")
52- self.assertDictEqual({
53- "status": "account with data",
54- "person": canonical_url(person),
55- "answers": canonical_url(person, rootsite="answers")
56- }, result)
57+ self.assertThat(result, ContainsDict({
58+ "status": Equals("account with data"),
59+ "person": Equals(canonical_url(person)),
60+ "answers": Contains(
61+ canonical_url(
62+ person, rootsite="answers"))}))
63
64 def test_account_data_questions_solved(self):
65 person = self.factory.makePerson(email="test@example.com")
66@@ -1347,11 +1349,12 @@ class TestGDPRUserRetrieval(TestCaseWithFactory):
67 with admin_logged_in():
68 question.setStatus(person, QuestionStatus.SOLVED, "solved!")
69 result = self.person_set.getUserData(u"test@example.com")
70- self.assertDictEqual({
71- "status": "account with data",
72- "person": canonical_url(person),
73- "answers": canonical_url(person, rootsite="answers")
74- }, result)
75+ self.assertThat(result, ContainsDict({
76+ "status": Equals("account with data"),
77+ "person": Equals(canonical_url(person)),
78+ "answers": Contains(
79+ canonical_url(
80+ person, rootsite="answers"))}))
81
82 def test_getUserOverview(self):
83 ppa = self.factory.makeArchive(owner=self.user)

Subscribers

People subscribed via source and target branches

to status/vote changes: