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
1=== modified file 'lib/lp/bugs/stories/bugs/xx-front-page-info.txt'
2--- lib/lp/bugs/stories/bugs/xx-front-page-info.txt 2010-01-19 15:31:04 +0000
3+++ lib/lp/bugs/stories/bugs/xx-front-page-info.txt 2010-02-18 14:25:23 +0000
4@@ -4,10 +4,13 @@
5 By default, projects are created without using any bugtracker, malone
6 or otherwise. To demonstrate this, a new project is created.
7
8+ >>> from zope.component import getUtility
9 >>> from canonical.launchpad.ftests import login, logout
10+ >>> from lp.registry.interfaces.person import IPersonSet
11 >>> login('foo.bar@canonical.com')
12+ >>> foobar = getUtility(IPersonSet).getByEmail('foo.bar@canonical.com')
13 >>> test_project = factory.makeProduct(
14- ... name='test-project', title='Simple Test Project')
15+ ... name='test-project', title='Simple Test Project', owner=foobar)
16 >>> logout()
17
18 The bugs home page for the project states that the project does
19@@ -18,6 +21,18 @@
20 >>> print extract_text(uses_malone_p)
21 Simple Test Project does not use Launchpad for bug tracking.
22
23+Only users who have permission to do so can enable bug tracking
24+for a project.
25+
26+ >>> find_tag_by_id(anon_browser.contents, 'no-malone-edit') is None
27+ True
28+
29+ >>> admin_browser.open('http://bugs.launchpad.dev/test-project')
30+ >>> enable_tracker = find_tag_by_id(
31+ ... admin_browser.contents, 'no-malone-edit')
32+ >>> print extract_text(enable_tracker)
33+ Enable bug tracking.
34+
35 The bugs home page for a project using Launchpad for bug tracking
36 shows controls for setting bug supervisor and states that no
37 bugs have been filed.
38
39=== modified file 'lib/lp/bugs/templates/bugtarget-bugs.pt'
40--- lib/lp/bugs/templates/bugtarget-bugs.pt 2010-02-12 12:29:58 +0000
41+++ lib/lp/bugs/templates/bugtarget-bugs.pt 2010-02-18 14:25:23 +0000
42@@ -165,7 +165,11 @@
43 <p id="no-malone"><strong><tal:project_title replace="context/title" /> does not use Launchpad for
44 bug tracking.</strong></p>
45
46- <p id="no-malone-edit"><a href="+edit">Enable bug tracking.</a></p>
47+ <p tal:condition="context/required:launchpad.Edit"
48+ id="no-malone-edit">
49+ <a tal:attributes="href string:${context/fmt:url/+edit}">Enable
50+ bug tracking.</a>
51+ </p>
52 </tal:not_uses_malone>
53
54 </div><!-- main -->