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
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2011-02-04 18:28:14 +0000
+++ lib/lp/soyuz/browser/archive.py 2011-02-09 10:13:20 +0000
@@ -55,7 +55,6 @@
55 SimpleVocabulary,55 SimpleVocabulary,
56 )56 )
57from zope.security.interfaces import Unauthorized57from zope.security.interfaces import Unauthorized
58from zope.security.proxy import removeSecurityProxy
5958
60from canonical.launchpad import _59from canonical.launchpad import _
61from canonical.launchpad.browser.librarian import FileNavigationMixin60from canonical.launchpad.browser.librarian import FileNavigationMixin
@@ -89,7 +88,6 @@
89 TextAreaEditorWidget,88 TextAreaEditorWidget,
90 TextLineEditorWidget,89 TextLineEditorWidget,
91 )90 )
92from lp.app.browser.stringformatter import FormattersAPI
93from lp.app.errors import NotFoundError91from lp.app.errors import NotFoundError
94from lp.app.widgets.itemswidgets import (92from lp.app.widgets.itemswidgets import (
95 LabeledMultiCheckBoxWidget,93 LabeledMultiCheckBoxWidget,
@@ -547,6 +545,24 @@
547class ArchiveViewBase(LaunchpadView):545class ArchiveViewBase(LaunchpadView):
548 """Common features for Archive view classes."""546 """Common features for Archive view classes."""
549547
548 def initialize(self):
549 # If the archive has publishing disabled, present a warning. If
550 # the current user has lp.Edit then add a link to +edit to fix
551 # this.
552 if not self.context.publish and self.context.is_active:
553 can_edit = check_permission('launchpad.Edit', self.context)
554 notification = "Publishing has been disabled for this archive."
555 if can_edit:
556 edit_url = canonical_url(self.context) + '/+edit'
557 notification += (
558 " <a href=%s>(re-enable publishing)</a>" % edit_url)
559 if self.context.private:
560 notification += (
561 " Since this archive is private, no builds are "
562 "being dispatched.")
563 self.request.response.addNotification(structured(notification))
564 super(ArchiveViewBase, self).initialize()
565
550 @cachedproperty566 @cachedproperty
551 def private(self):567 def private(self):
552 return self.context.private568 return self.context.private
553569
=== modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py'
--- lib/lp/soyuz/browser/tests/test_archive_packages.py 2010-12-08 19:03:17 +0000
+++ lib/lp/soyuz/browser/tests/test_archive_packages.py 2011-02-09 10:13:20 +0000
@@ -19,7 +19,10 @@
19 MatchesAny,19 MatchesAny,
20 )20 )
21from zope.security.interfaces import Unauthorized21from zope.security.interfaces import Unauthorized
22from zope.security.proxy import removeSecurityProxy
2223
24from canonical.launchpad.webapp.authentication import LaunchpadPrincipal
25from canonical.launchpad.testing.pages import get_feedback_messages
23from canonical.launchpad.webapp import canonical_url26from canonical.launchpad.webapp import canonical_url
24from canonical.testing.layers import LaunchpadFunctionalLayer27from canonical.testing.layers import LaunchpadFunctionalLayer
25from canonical.launchpad.utilities.celebrities import ILaunchpadCelebrities28from canonical.launchpad.utilities.celebrities import ILaunchpadCelebrities
@@ -117,6 +120,52 @@
117 return create_initialized_view(120 return create_initialized_view(
118 ppa, "+packages", query_string=query_string)121 ppa, "+packages", query_string=query_string)
119122
123 def assertNotifications(self, ppa, notification, person=None):
124 # Assert that while requesting a 'ppa' page as 'person', the
125 # 'notification' appears.
126 if person is not None:
127 login_person(ppa.owner)
128 principal = LaunchpadPrincipal(
129 ppa.owner.account.id, ppa.owner.displayname,
130 ppa.owner.displayname, ppa.owner)
131 else:
132 principal = None
133 page = create_initialized_view(
134 ppa, "+packages", principal=principal).render()
135 notifications = get_feedback_messages(page)
136 self.assertIn(notification, notifications)
137
138 def test_warning_for_disabled_publishing(self):
139 # Ensure that a notification is shown when archive.publish
140 # is False.
141 ppa = self.factory.makeArchive()
142 removeSecurityProxy(ppa).publish = False
143 self.assertNotifications(
144 ppa,
145 "Publishing has been disabled for this archive. (re-enable "
146 "publishing)",
147 person=ppa.owner)
148
149 def test_warning_for_disabled_publishing_with_private_ppa(self):
150 # Ensure that a notification is shown when archive.publish
151 # is False warning that builds won't get dispatched.
152 ppa = self.factory.makeArchive(private=True)
153 removeSecurityProxy(ppa).publish = False
154 self.assertNotifications(
155 ppa,
156 "Publishing has been disabled for this archive. (re-enable "
157 "publishing) Since this archive is private, no builds are being "
158 "dispatched.",
159 person=ppa.owner)
160
161 def test_warning_for_disabled_publishing_with_anonymous_user(self):
162 # The warning notification doesn't mention the Change details
163 # page.
164 ppa = self.factory.makeArchive()
165 removeSecurityProxy(ppa).publish = False
166 self.assertNotifications(
167 ppa, 'Publishing has been disabled for this archive.')
168
120 def test_ppa_packages_menu_is_enabled(self):169 def test_ppa_packages_menu_is_enabled(self):
121 joe = self.factory.makePerson()170 joe = self.factory.makePerson()
122 ppa = self.factory.makeArchive()171 ppa = self.factory.makeArchive()
123172
=== modified file 'lib/lp/soyuz/interfaces/archive.py'
--- lib/lp/soyuz/interfaces/archive.py 2011-02-03 17:38:38 +0000
+++ lib/lp/soyuz/interfaces/archive.py 2011-02-09 10:13:20 +0000
@@ -282,7 +282,9 @@
282282
283 publish = Bool(283 publish = Bool(
284 title=_("Publish"), required=False,284 title=_("Publish"), required=False,
285 description=_("Update the APT archive."))285 description=_("Whether or not to update the APT repository. If "
286 "disabled, nothing will be published. If the archive is "
287 "private then additionally no builds will be dispatched."))
286288
287 # This is redefined from IPrivacy.private because the attribute is289 # This is redefined from IPrivacy.private because the attribute is
288 # read-only. The value is guarded by a validator.290 # read-only. The value is guarded by a validator.