Merge lp:~jcsackett/launchpad/code-configuration-652142 into lp:launchpad

Proposed by j.c.sackett
Status: Merged
Approved by: j.c.sackett
Approved revision: no longer in the source branch.
Merged at revision: 11720
Proposed branch: lp:~jcsackett/launchpad/code-configuration-652142
Merge into: lp:launchpad
Diff against target: 154 lines (+52/-29)
4 files modified
lib/lp/code/browser/branchlisting.py (+6/-1)
lib/lp/code/browser/tests/test_product.py (+21/-1)
lib/lp/code/stories/branches/xx-product-branches.txt (+7/-12)
lib/lp/code/templates/product-branch-summary.pt (+18/-15)
To merge this branch: bzr merge lp:~jcsackett/launchpad/code-configuration-652142
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+38015@code.launchpad.net

Commit message

Fixes the message displayed to users on product code pages with no branches; previously users without configuration rights were told they could set things up when they couldn't.

Description of the change

Summary
=======

The bulleted list of steps to take for a product with no branches implies that
a user can configure branches/codehosting for the product regardless of
whether or not they can.

This branch simply removes the messages about how to set up branches for the
product if the user doesn't have the permissions to configure code for the
product.

Proposed fix
============

Adds a can_configure_branches checker to the branch views, and uses that to
filter the messages displayed to users, so users who can't configure things
aren't led to believe they can.

Implementation details
======================

As above.

Tests
=====

bin/test -m lp.code.browser.tests.test_product

Demo and Q/A
============

If you go to code.launchpad.dev/mega-money-maker logged in as
<email address hidden>, you will see the bulleted list and a configuration
link.

If you logout and go to the same page, you will only see the message saying
that LP doesn't know where code is hosted, and that the product has no
branches.

Lint
====

make lint output:

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/code/browser/branchlisting.py
  lib/lp/code/browser/tests/test_product.py
  lib/lp/code/templates/product-branch-summary.pt

./lib/lp/code/templates/product-branch-summary.pt
      44: Line has trailing whitespace.

The trailing whitespace is a space needed in the displayed text on the webpage.

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

Very clear.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/browser/branchlisting.py'
--- lib/lp/code/browser/branchlisting.py 2010-09-28 22:21:51 +0000
+++ lib/lp/code/browser/branchlisting.py 2010-10-15 14:29:43 +0000
@@ -406,7 +406,8 @@
406 @cachedproperty406 @cachedproperty
407 def official_package_links_map(self):407 def official_package_links_map(self):
408 """Return a map from branch id to a list of package links."""408 """Return a map from branch id to a list of package links."""
409 links = self._query_optimiser.getOfficialSourcePackageLinksForBranches(409 query_optimiser = self._query_optimiser
410 links = query_optimiser.getOfficialSourcePackageLinksForBranches(
410 self._visible_branch_ids)411 self._visible_branch_ids)
411 result = {}412 result = {}
412 for link in links:413 for link in links:
@@ -1180,6 +1181,10 @@
1180 'in this project.')1181 'in this project.')
1181 return message % self.context.displayname1182 return message % self.context.displayname
11821183
1184 def can_configure_branches(self):
1185 """Whether or not the user can configure branches."""
1186 return check_permission("launchpad.Edit", self.context)
1187
11831188
1184class ProductBranchStatisticsView(BranchCountSummaryView,1189class ProductBranchStatisticsView(BranchCountSummaryView,
1185 ProductBranchListingView):1190 ProductBranchListingView):
11861191
=== modified file 'lib/lp/code/browser/tests/test_product.py'
--- lib/lp/code/browser/tests/test_product.py 2010-10-04 19:50:45 +0000
+++ lib/lp/code/browser/tests/test_product.py 2010-10-15 14:29:43 +0000
@@ -26,6 +26,7 @@
26 BranchVisibilityRule,26 BranchVisibilityRule,
27 )27 )
28from lp.code.interfaces.revision import IRevisionSet28from lp.code.interfaces.revision import IRevisionSet
29from lp.code.publisher import CodeLayer
29from lp.testing import (30from lp.testing import (
30 ANONYMOUS,31 ANONYMOUS,
31 BrowserTestCase,32 BrowserTestCase,
@@ -34,7 +35,10 @@
34 TestCaseWithFactory,35 TestCaseWithFactory,
35 time_counter,36 time_counter,
36 )37 )
37from lp.testing.views import create_initialized_view38from lp.testing.views import (
39 create_view,
40 create_initialized_view,
41 )
3842
3943
40class ProductTestBase(TestCaseWithFactory):44class ProductTestBase(TestCaseWithFactory):
@@ -294,5 +298,21 @@
294 self.assertTextMatchesExpressionIgnoreWhitespace(expected, text)298 self.assertTextMatchesExpressionIgnoreWhitespace(expected, text)
295299
296300
301class TestCanConfigureBranches(TestCaseWithFactory):
302
303 layer = DatabaseFunctionalLayer
304
305 def test_cannot_configure_branches_product_no_edit_permission(self):
306 product = self.factory.makeProduct()
307 view = create_view(product, '+branches', layer=CodeLayer)
308 self.assertEqual(False, view.can_configure_branches())
309
310 def test_can_configure_branches_product_with_edit_permission(self):
311 product = self.factory.makeProduct()
312 login_person(product.owner)
313 view = create_view(product, '+branches', layer=CodeLayer)
314 self.assertEqual(True, view.can_configure_branches())
315
316
297def test_suite():317def test_suite():
298 return unittest.TestLoader().loadTestsFromName(__name__)318 return unittest.TestLoader().loadTestsFromName(__name__)
299319
=== modified file 'lib/lp/code/stories/branches/xx-product-branches.txt'
--- lib/lp/code/stories/branches/xx-product-branches.txt 2010-09-28 19:25:54 +0000
+++ lib/lp/code/stories/branches/xx-product-branches.txt 2010-10-15 14:29:43 +0000
@@ -37,14 +37,12 @@
37 ... return find_tag_by_id(browser.contents, 'branch-summary')37 ... return find_tag_by_id(browser.contents, 'branch-summary')
38 >>> summary = get_summary(browser)38 >>> summary = get_summary(browser)
39 >>> print extract_text(summary)39 >>> print extract_text(summary)
40 Launchpad does not know where The Gnome Panel Applets hosts its code.40 Launchpad does not know where The Gnome Panel Applets
41 There are no branches for Gnome Applets in Launchpad. You can change this by:41 hosts its code.
42 activating code hosting directly on Launchpad. (read more)42 There are no branches for Gnome Applets
43 asking Launchpad to mirror a Bazaar branch hosted elsewhere. (read more)43 in Launchpad.
44 asking Launchpad to import code from Git, Subversion, or CVS into a44 Getting started
45 Bazaar branch. (read more)45 with code hosting in Launchpad.
46 Getting started with code hosting in Launchpad.
47
4846
49 If there are Bazaar branches of Gnome Applets in a publicly47 If there are Bazaar branches of Gnome Applets in a publicly
50 accessible location, Launchpad can act as a mirror of the branch48 accessible location, Launchpad can act as a mirror of the branch
@@ -54,13 +52,10 @@
54 Launchpad can import code from CVS, Subversion, Mercurial or Git52 Launchpad can import code from CVS, Subversion, Mercurial or Git
55 into Bazaar branches. Read more...53 into Bazaar branches. Read more...
5654
57The 'Read more' links go to the help wiki.55The 'Help' links go to the help wiki.
5856
59 >>> for anchor in summary.fetch('a'):57 >>> for anchor in summary.fetch('a'):
60 ... print anchor['href']58 ... print anchor['href']
61 https://help.launchpad.net/Code/UploadingABranch
62 https://help.launchpad.net/Code/MirroredBranches
63 https://help.launchpad.net/VcsImports
64 https://help.launchpad.net/Code59 https://help.launchpad.net/Code
6560
6661
6762
=== modified file 'lib/lp/code/templates/product-branch-summary.pt'
--- lib/lp/code/templates/product-branch-summary.pt 2010-09-28 19:25:54 +0000
+++ lib/lp/code/templates/product-branch-summary.pt 2010-10-15 14:29:43 +0000
@@ -42,21 +42,24 @@
4242
43 <tal:no-branches condition="not: view/branch_count">43 <tal:no-branches condition="not: view/branch_count">
44 There are no branches for <tal:project-name replace="context/displayname"/>44 There are no branches for <tal:project-name replace="context/displayname"/>
45 in Launchpad. You can change this by:45 in Launchpad.
4646 <tal:can-configure condition="view/can_configure_branches">
47 <ul class="bulleted" style="margin-top:1em;">47 You can change this by:
4848
49 <li>activating code hosting directly on49 <ul class="bulleted" style="margin-top:1em;">
50 Launchpad. (<a href="https://help.launchpad.net/Code/UploadingABranch">read50
51 more</a>)</li>51 <li>activating code hosting directly on
5252 Launchpad. (<a href="https://help.launchpad.net/Code/UploadingABranch">read
53 <li>asking Launchpad to mirror a Bazaar branch hosted53 more</a>)</li>
54 elsewhere. (<a href="https://help.launchpad.net/Code/MirroredBranches">read54
55 more</a>)</li>55 <li>asking Launchpad to mirror a Bazaar branch hosted
5656 elsewhere. (<a href="https://help.launchpad.net/Code/MirroredBranches">read
57 <li>asking Launchpad to import code from Git, Subversion, or CVS into a57 more</a>)</li>
58 Bazaar branch. (<a href="https://help.launchpad.net/VcsImports">read more</a>)</li>58
59 </ul>59 <li>asking Launchpad to import code from Git, Subversion, or CVS into a
60 Bazaar branch. (<a href="https://help.launchpad.net/VcsImports">read more</a>)</li>
61 </ul>
62 </tal:can-configure>
60 </tal:no-branches>63 </tal:no-branches>
6164
62 <tal:has-branches condition="view/branch_count">65 <tal:has-branches condition="view/branch_count">