Merge lp:~jcsackett/launchpad/private-bugs-404 into lp:launchpad

Proposed by j.c.sackett
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 12847
Proposed branch: lp:~jcsackett/launchpad/private-bugs-404
Merge into: lp:launchpad
Diff against target: 89 lines (+39/-4)
3 files modified
lib/lp/bugs/browser/tests/test_bug_views.py (+26/-0)
lib/lp/bugs/templates/bug-portlet-actions.pt (+1/-1)
lib/lp/bugs/templates/bugtask-index.pt (+12/-3)
To merge this branch: bzr merge lp:~jcsackett/launchpad/private-bugs-404
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+57244@code.launchpad.net

Commit message

[incr] [r=danilo][bug=434733] Fixes links to private bugs so that they're only text if the user can't see the bug.

Description of the change

Summary
=======

When a public bug is marked as a duplicate of a private bug, the duplicate listings in the portlet do not provide links, just text. However, the warning below the page links to the private bug, which then yields a 404. We shouldn't generate 404ing links if we can avoid it.

This just changes that link text to regular text when the user can't see the master bug, and adds a test to ensure that it's working.

Preimplementation
================

Spoke with Curtis Hovey

Implementation
==============
lib/lp/bugs/browser/tests/test_bug_views.py
-------------------------------------------
Test

lib/lp/bugs/templates/bugtask-index.pt
--------------------------------------
Altered dupe link in the warning above the comment box to only create a link if the master bug is viewable by the user, and just show the text otherwise.
Tests
=====

QA
==
Find (or create) a public duplicate of a private bug--the warning before the comment form should list the private bug, but should not link to it.

Lint
====
make lint output:

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/browser/tests/test_bug_views.py
  lib/lp/bugs/templates/bugtask-index.pt

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

This is good, but possibly incomplete.

If the master bug isn't viewable, perhaps we shouldn't list the bug
number *either* - the whole point being that said bug is invisible to
the submitter. We've a cluster of bugs around the behaviour and UI of
duplicates-against-private-bugs, and similarly in the planning for bug
relationships and better privacy, the idea was put forward to simply
hide relationships (of which duplicate is one that we already have)
where the other side was invisible to the viewing user.

Hmm, in writing this I realise that actually the thing is way to
complex to shoe-horn in here.

But I do think we should do something to help with the support load -
folk will be confused when its not a link and they can't see it.
Perhaps 'duplicate of bug 42 which is embargoed (you cannot view it)'.

Or something.

Revision history for this message
j.c.sackett (jcsackett) wrote :

I was actually thinking something similar, but I wanted to keep consistent with the portlet, which I don't think has room for the expanded text.

I'll work on some phrasing that works both above the comment box and in the portlet, and make those changes.

Revision history for this message
Данило Шеган (danilo) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/tests/test_bug_views.py'
2--- lib/lp/bugs/browser/tests/test_bug_views.py 2011-04-05 18:33:58 +0000
3+++ lib/lp/bugs/browser/tests/test_bug_views.py 2011-04-17 18:14:37 +0000
4@@ -7,13 +7,16 @@
5
6 from zope.component import getUtility
7
8+from canonical.launchpad.webapp.publisher import canonical_url
9 from canonical.launchpad.webapp.interfaces import IOpenLaunchBag
10 from canonical.launchpad.webapp.servers import LaunchpadTestRequest
11+from canonical.launchpad.testing.pages import find_tag_by_id
12 from canonical.testing.layers import DatabaseFunctionalLayer
13
14 from lp.services.features.testing import FeatureFixture
15 from lp.services.features import get_relevant_feature_controller
16 from lp.testing import (
17+ BrowserTestCase,
18 feature_flags,
19 person_logged_in,
20 TestCaseWithFactory,
21@@ -21,6 +24,29 @@
22 from lp.testing.views import create_initialized_view
23
24
25+class TestPrivateBugLinks(BrowserTestCase):
26+
27+ layer = DatabaseFunctionalLayer
28+
29+ def makeDupeOfPrivateBug(self):
30+ bug = self.factory.makeBug()
31+ dupe = self.factory.makeBug()
32+ with person_logged_in(bug.owner):
33+ bug.setPrivate(private=True, who=bug.owner)
34+ dupe.markAsDuplicate(bug)
35+ return dupe
36+
37+ def test_private_bugs_are_not_linked_without_permission(self):
38+ bug = self.makeDupeOfPrivateBug()
39+ url = canonical_url(bug, rootsite="bugs")
40+ browser = self.getUserBrowser(url)
41+ dupe_warning = find_tag_by_id(
42+ browser.contents,
43+ 'warning-comment-on-duplicate')
44+ # There is no link in the dupe_warning.
45+ self.assertTrue('href' not in dupe_warning)
46+
47+
48 class TestBugPortletSubscribers(TestCaseWithFactory):
49
50 layer = DatabaseFunctionalLayer
51
52=== modified file 'lib/lp/bugs/templates/bug-portlet-actions.pt'
53--- lib/lp/bugs/templates/bug-portlet-actions.pt 2010-09-21 09:37:06 +0000
54+++ lib/lp/bugs/templates/bug-portlet-actions.pt 2011-04-17 18:14:37 +0000
55@@ -42,7 +42,7 @@
56 >bug #42</a>
57 <span
58 tal:condition="not:duplicateof/required:launchpad.View"
59- tal:replace="string:bug #${duplicateof/id}" />
60+ tal:replace="string:a private bug" />
61 </span>
62 </tal:block>
63 </div>
64
65=== modified file 'lib/lp/bugs/templates/bugtask-index.pt'
66--- lib/lp/bugs/templates/bugtask-index.pt 2011-04-04 01:13:22 +0000
67+++ lib/lp/bugs/templates/bugtask-index.pt 2011-04-17 18:14:37 +0000
68@@ -296,9 +296,18 @@
69 class="warning message"
70 id="warning-comment-on-duplicate">
71 Remember, this bug report is a duplicate of
72- <a href="#" tal:attributes="href
73- context/bug/duplicateof/fmt:url">bug #<span
74- tal:replace="context/bug/duplicateof/id">42</span></a>.
75+ <a
76+ tal:define="duplicateof context/bug/duplicateof"
77+ tal:condition="duplicateof/required:launchpad.View"
78+ tal:attributes="href duplicateof/fmt:url; title
79+ duplicateof/title; style string:margin-right: 4px;
80+ id string:duplicate-of-warning-link;"
81+ tal:content="string:bug #${duplicateof/id}."
82+ >bug #42</a>
83+ <span
84+ tal:define="duplicateof context/bug/duplicateof"
85+ tal:condition="not:duplicateof/required:launchpad.View"
86+ tal:replace="string: a private bug." />
87 Comment here only if you think the duplicate status is wrong.
88 </div>
89 <h2>Add comment</h2>