Merge lp:~deryck/launchpad/enable-tracking-link-perms-512378 into lp:launchpad

Proposed by Deryck Hodge
Status: Merged
Approved by: Deryck Hodge
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~deryck/launchpad/enable-tracking-link-perms-512378
Merge into: lp:launchpad
Diff against target: 54 lines (+21/-2)
2 files modified
lib/lp/bugs/stories/bugs/xx-front-page-info.txt (+16/-1)
lib/lp/bugs/templates/bugtarget-bugs.pt (+5/-1)
To merge this branch: bzr merge lp:~deryck/launchpad/enable-tracking-link-perms-512378
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+19600@code.launchpad.net

Commit message

Check launchpad.Edit permissions for a project before offering a link to enable bug tracking.

To post a comment you must log in.
Revision history for this message
Deryck Hodge (deryck) wrote :

This is a fix for bug 512378.

For projects that don't use malone for bug tracking, we changed the bugs
home page (i.e. https://bugs.edge.launchpad.net/malone/) to not display
anything except a message that "[PROJECT] doesn't use Launchpad for bug
tracking." There was also a link to "Enable bug tracking."

Formerly, this link didn't check to see if the user had permissions to
edit the project, so the link showed for everyone, even if they couldn't
change the setting. My branch fixes this and only shows the link to the
appropriate person.

== Tests ==

The home page info test has been updated to now confirm the link is correct.

./bin/test -cvvt xx-front-page-info.txt

== Demo and Q/A ==

To demo on the dev server, create a new project and don't enable bug
tracking. Ensure that you (the owner) can see the link on the project's
bugs home page. Log out and back in again as another user and confirm
this user doesn't see the link.

To QA on edge or staging, visit a project that doesn't use Launchpad for
bug tracking, e.g. https://bugs.edge.launchpad.net/firefox. Confirm
that there is no link to "Enable bug tracking."

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/bugs/browser/bugtarget.py
  lib/lp/bugs/stories/bugs/xx-front-page-info.txt
  lib/lp/bugs/templates/bugtarget-bugs.pt

Revision history for this message
Abel Deuring (adeuring) wrote :

Hi Deryck,

A nice branch. I have only two minor comments.

> + elif (self.user == self.context.owner or
> + self.user.inTeam(self.context.owner)):

I think the first check is not strictly necessary, self.user.inTeam(self.context.owner) should return True, if self.user == self.context.owner. OTOH, the equaliy check is probably faster that the inTeam() call.

And I wondered if we should also show the link for admins. Again, that's not really important, because the LOSAs know for sure how to change the official_malone flag of a project.

review: Approve (code)
Revision history for this message
Deryck Hodge (deryck) wrote :

BjornT had an even better suggestion -- to check launchpad.Edit from the template. I've updated the branch to do this now, which is definitely nicer.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/stories/bugs/xx-front-page-info.txt'
--- lib/lp/bugs/stories/bugs/xx-front-page-info.txt 2010-01-19 15:31:04 +0000
+++ lib/lp/bugs/stories/bugs/xx-front-page-info.txt 2010-02-18 14:25:23 +0000
@@ -4,10 +4,13 @@
4By default, projects are created without using any bugtracker, malone4By default, projects are created without using any bugtracker, malone
5or otherwise. To demonstrate this, a new project is created.5or otherwise. To demonstrate this, a new project is created.
66
7 >>> from zope.component import getUtility
7 >>> from canonical.launchpad.ftests import login, logout8 >>> from canonical.launchpad.ftests import login, logout
9 >>> from lp.registry.interfaces.person import IPersonSet
8 >>> login('foo.bar@canonical.com')10 >>> login('foo.bar@canonical.com')
11 >>> foobar = getUtility(IPersonSet).getByEmail('foo.bar@canonical.com')
9 >>> test_project = factory.makeProduct(12 >>> test_project = factory.makeProduct(
10 ... name='test-project', title='Simple Test Project')13 ... name='test-project', title='Simple Test Project', owner=foobar)
11 >>> logout()14 >>> logout()
1215
13The bugs home page for the project states that the project does16The bugs home page for the project states that the project does
@@ -18,6 +21,18 @@
18 >>> print extract_text(uses_malone_p)21 >>> print extract_text(uses_malone_p)
19 Simple Test Project does not use Launchpad for bug tracking.22 Simple Test Project does not use Launchpad for bug tracking.
2023
24Only users who have permission to do so can enable bug tracking
25for a project.
26
27 >>> find_tag_by_id(anon_browser.contents, 'no-malone-edit') is None
28 True
29
30 >>> admin_browser.open('http://bugs.launchpad.dev/test-project')
31 >>> enable_tracker = find_tag_by_id(
32 ... admin_browser.contents, 'no-malone-edit')
33 >>> print extract_text(enable_tracker)
34 Enable bug tracking.
35
21The bugs home page for a project using Launchpad for bug tracking36The bugs home page for a project using Launchpad for bug tracking
22shows controls for setting bug supervisor and states that no37shows controls for setting bug supervisor and states that no
23bugs have been filed.38bugs have been filed.
2439
=== modified file 'lib/lp/bugs/templates/bugtarget-bugs.pt'
--- lib/lp/bugs/templates/bugtarget-bugs.pt 2010-02-12 12:29:58 +0000
+++ lib/lp/bugs/templates/bugtarget-bugs.pt 2010-02-18 14:25:23 +0000
@@ -165,7 +165,11 @@
165 <p id="no-malone"><strong><tal:project_title replace="context/title" /> does not use Launchpad for165 <p id="no-malone"><strong><tal:project_title replace="context/title" /> does not use Launchpad for
166 bug tracking.</strong></p>166 bug tracking.</strong></p>
167167
168 <p id="no-malone-edit"><a href="+edit">Enable bug tracking.</a></p>168 <p tal:condition="context/required:launchpad.Edit"
169 id="no-malone-edit">
170 <a tal:attributes="href string:${context/fmt:url/+edit}">Enable
171 bug tracking.</a>
172 </p>
169 </tal:not_uses_malone>173 </tal:not_uses_malone>
170174
171 </div><!-- main -->175 </div><!-- main -->