Merge lp:~julian-edwards/launchpad/publish-warning-bug-715116 into lp:launchpad

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 12350
Proposed branch: lp:~julian-edwards/launchpad/publish-warning-bug-715116
Merge into: lp:launchpad
Diff against target: 127 lines (+70/-3)
3 files modified
lib/lp/soyuz/browser/archive.py (+18/-2)
lib/lp/soyuz/browser/tests/test_archive_packages.py (+49/-0)
lib/lp/soyuz/interfaces/archive.py (+3/-1)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/publish-warning-bug-715116
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+48952@code.launchpad.net

Commit message

[r=leonardr][bug=715116] Add a big informational notice on the PPA pages if publishing is disabled.

Description of the change

= Summary =
Fix bug 715116

== Proposed fix ==
A PPA can have apparently "stuck" publications and if it's private, stuck
builds, if someone has turned the publishing flag off.

This branch adds a big informational notice on the PPA pages if the publishing
is disabled.

== Implementation details ==

There's three different message segments added depending on some criteria:
 * The basic "publishing is disabled" if that's the case
 * Add a link to "Change details" if the requesing user has lp.edit
 * Add a message about stuck builds if the PPA is private.

As a bonus, fix the really crappy description text on the "publish" flag on
the +edit page.

== Tests ==
bin/test -cvv test_archive_packages test_warning_for_disabled_publishing

== Demo and Q/A ==

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/soyuz/browser/tests/test_archive_packages.py
  lib/lp/soyuz/interfaces/archive.py
  lib/lp/soyuz/browser/archive.py

./lib/lp/soyuz/interfaces/archive.py
     586: E301 expected 1 blank line, found 0
     714: E301 expected 1 blank line, found 0
     737: E301 expected 1 blank line, found 0
     760: E301 expected 1 blank line, found 0
     860: E301 expected 1 blank line, found 0
     894: E501 line too long (84 characters)
     894: Line exceeds 78 characters.

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

The code and tests look good but I think the wording has some problems. Let me nitpick your wording to try and save you a full UI review.

1. "Publishing has been disabled for this archive" is a full sentence and needs a period after it.

2. "Go to the Change details page..." is also a full sentence sentence.

3. Should "no builds will be dispatched" be "no builds are being dispatched"? Isn't it something that's (not) happening continuously, right now?

4. I'm not happy with the wording "Go to the Change details page", or with sticking a "Note:" in there with no special markup. How about one of these:

"Publishing has been disabled for this archive. Since this archive is private, no builds are being dispatched. You can <a>re-enable publishing</a>."

"Publishing has been disabled for this archive. <a>(Re-enable it.)</a> Since this archive is private, no builds are being dispatched."

What do you think?

I also don't understand why "no builds are being dispatched" follows from "this archive is private". Why are builds dispatched for public archives that have publishing disabled? Will the actual users understand?

review: Approve
Revision history for this message
William Grant (wgrant) wrote :

Could you add a full stop to the end of "Publishing has been disabled for this archive"? I'm also a little wary about having "Whether" in the field description.

Revision history for this message
Julian Edwards (julian-edwards) wrote :

On Tuesday 08 February 2011 18:36:10 you wrote:
> Review: Approve

Thanks for the review Leonard, and thanks for the critique of the wording.

> What do you think?

Much better, I've changed it a little more so it will look like:

            "Publishing has been disabled for this archive. (re-enable "
            "publishing) Since this archive is private, no builds are being "
            "dispatched."

> I also don't understand why "no builds are being dispatched" follows from
> "this archive is private". Why are builds dispatched for public archives
> that have publishing disabled? Will the actual users understand?

The reason for this is too technical to put on that page really, but the
upshot is that for security reasons the builders require authenticated access
to a place where they can download the source before building it. The only
place we have right now is the repo itself, thusly requiring the sources to be
published first.

The branch is in ec2 now, thanks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/browser/archive.py'
2--- lib/lp/soyuz/browser/archive.py 2011-02-04 18:28:14 +0000
3+++ lib/lp/soyuz/browser/archive.py 2011-02-09 10:13:20 +0000
4@@ -55,7 +55,6 @@
5 SimpleVocabulary,
6 )
7 from zope.security.interfaces import Unauthorized
8-from zope.security.proxy import removeSecurityProxy
9
10 from canonical.launchpad import _
11 from canonical.launchpad.browser.librarian import FileNavigationMixin
12@@ -89,7 +88,6 @@
13 TextAreaEditorWidget,
14 TextLineEditorWidget,
15 )
16-from lp.app.browser.stringformatter import FormattersAPI
17 from lp.app.errors import NotFoundError
18 from lp.app.widgets.itemswidgets import (
19 LabeledMultiCheckBoxWidget,
20@@ -547,6 +545,24 @@
21 class ArchiveViewBase(LaunchpadView):
22 """Common features for Archive view classes."""
23
24+ def initialize(self):
25+ # If the archive has publishing disabled, present a warning. If
26+ # the current user has lp.Edit then add a link to +edit to fix
27+ # this.
28+ if not self.context.publish and self.context.is_active:
29+ can_edit = check_permission('launchpad.Edit', self.context)
30+ notification = "Publishing has been disabled for this archive."
31+ if can_edit:
32+ edit_url = canonical_url(self.context) + '/+edit'
33+ notification += (
34+ " <a href=%s>(re-enable publishing)</a>" % edit_url)
35+ if self.context.private:
36+ notification += (
37+ " Since this archive is private, no builds are "
38+ "being dispatched.")
39+ self.request.response.addNotification(structured(notification))
40+ super(ArchiveViewBase, self).initialize()
41+
42 @cachedproperty
43 def private(self):
44 return self.context.private
45
46=== modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py'
47--- lib/lp/soyuz/browser/tests/test_archive_packages.py 2010-12-08 19:03:17 +0000
48+++ lib/lp/soyuz/browser/tests/test_archive_packages.py 2011-02-09 10:13:20 +0000
49@@ -19,7 +19,10 @@
50 MatchesAny,
51 )
52 from zope.security.interfaces import Unauthorized
53+from zope.security.proxy import removeSecurityProxy
54
55+from canonical.launchpad.webapp.authentication import LaunchpadPrincipal
56+from canonical.launchpad.testing.pages import get_feedback_messages
57 from canonical.launchpad.webapp import canonical_url
58 from canonical.testing.layers import LaunchpadFunctionalLayer
59 from canonical.launchpad.utilities.celebrities import ILaunchpadCelebrities
60@@ -117,6 +120,52 @@
61 return create_initialized_view(
62 ppa, "+packages", query_string=query_string)
63
64+ def assertNotifications(self, ppa, notification, person=None):
65+ # Assert that while requesting a 'ppa' page as 'person', the
66+ # 'notification' appears.
67+ if person is not None:
68+ login_person(ppa.owner)
69+ principal = LaunchpadPrincipal(
70+ ppa.owner.account.id, ppa.owner.displayname,
71+ ppa.owner.displayname, ppa.owner)
72+ else:
73+ principal = None
74+ page = create_initialized_view(
75+ ppa, "+packages", principal=principal).render()
76+ notifications = get_feedback_messages(page)
77+ self.assertIn(notification, notifications)
78+
79+ def test_warning_for_disabled_publishing(self):
80+ # Ensure that a notification is shown when archive.publish
81+ # is False.
82+ ppa = self.factory.makeArchive()
83+ removeSecurityProxy(ppa).publish = False
84+ self.assertNotifications(
85+ ppa,
86+ "Publishing has been disabled for this archive. (re-enable "
87+ "publishing)",
88+ person=ppa.owner)
89+
90+ def test_warning_for_disabled_publishing_with_private_ppa(self):
91+ # Ensure that a notification is shown when archive.publish
92+ # is False warning that builds won't get dispatched.
93+ ppa = self.factory.makeArchive(private=True)
94+ removeSecurityProxy(ppa).publish = False
95+ self.assertNotifications(
96+ ppa,
97+ "Publishing has been disabled for this archive. (re-enable "
98+ "publishing) Since this archive is private, no builds are being "
99+ "dispatched.",
100+ person=ppa.owner)
101+
102+ def test_warning_for_disabled_publishing_with_anonymous_user(self):
103+ # The warning notification doesn't mention the Change details
104+ # page.
105+ ppa = self.factory.makeArchive()
106+ removeSecurityProxy(ppa).publish = False
107+ self.assertNotifications(
108+ ppa, 'Publishing has been disabled for this archive.')
109+
110 def test_ppa_packages_menu_is_enabled(self):
111 joe = self.factory.makePerson()
112 ppa = self.factory.makeArchive()
113
114=== modified file 'lib/lp/soyuz/interfaces/archive.py'
115--- lib/lp/soyuz/interfaces/archive.py 2011-02-03 17:38:38 +0000
116+++ lib/lp/soyuz/interfaces/archive.py 2011-02-09 10:13:20 +0000
117@@ -282,7 +282,9 @@
118
119 publish = Bool(
120 title=_("Publish"), required=False,
121- description=_("Update the APT archive."))
122+ description=_("Whether or not to update the APT repository. If "
123+ "disabled, nothing will be published. If the archive is "
124+ "private then additionally no builds will be dispatched."))
125
126 # This is redefined from IPrivacy.private because the attribute is
127 # read-only. The value is guarded by a validator.