> Hi Edwin. > > This this was a nice feature to use on the sp page. I think we should consider > using it on the dsp page: https://launchpad.dev/ubuntu/+source/evolution. We > have a post back that some people have expressed concern about how easy it is > to make a mistake. I would not say this is change we must do because the post > back always returns the user to the dsp page--using the sp as the next_url > would be confusing. > > I think we should remove the edit/remove links from the +packaging listing. > There is not enough information on this page to make that decision. This was supposed to be a simple change for the UI review. It has grown quite large, so I can create a new merge proposal if you would like. I started off trying to use +remove-packaging page for the $distrosourcepackage/+packages page, but I saw that the replaced code was also used by $product/+packages page, so I changed that page also. After I got the +remove-packaging page to return to the previous page, I discovered that the edit link on the $distrosourcepackage/+packages was returning you to a different page. All these changes broke a ton of tests. Pages to check -------------- The edit and remove buttons for each series are hidden now. https://launchpad.dev/ubuntu/hoary/+packaging The remove button now takes you to the $sourcepackage/+remove-packaging page, and the edit button no https://launchpad.dev/ubuntu/+source/evolution The remove button now takes you to the $sourcepackage/+remove-packaging page. https://launchpad.dev/evolution/+packages This page shouldn't have changed, but if you want to check that the show_edit_buttons annotation is passed correctly, you'll need to look at it. https://launchpad.dev/ubuntu/hoary/+source/evolution Implementation details ---------------------- Removed trailing white-space. lib/canonical/launchpad/icing/style-3-0.css.in Added Mixin to enable forms to return to their referring page. lib/canonical/launchpad/templates/launchpad-form.pt lib/canonical/launchpad/webapp/launchpadform.py Use the ReturnToReferrerMixin that provides the cancel_url and next_url. Hide the edit/remove buttons by default, but show them in the annotations portlet, because its view sets request.annotations['show_edit_buttons']. sourcepackage-upstream-connections.pt now has it's own view, since it can't share the view with annotations portlet or show_edit_buttons would always be true. lib/lp/registry/templates/sourcepackage-upstream-connections.pt lib/lp/registry/browser/sourcepackage.py lib/lp/registry/browser/tests/packaging-views.txt lib/lp/registry/browser/configure.zcml Removed PackagingDeleteView and related code. lib/lp/registry/browser/distributionsourcepackage.py lib/lp/registry/browser/packaging.py lib/lp/registry/browser/product.py lib/lp/registry/templates/distributionsourcepackage-index.pt lib/lp/registry/templates/product-packages.pt Added error message for when a user loads this page after the upstream link has been deleted by someone else. lib/lp/registry/templates/sourcepackage-remove-packaging.pt Tests: lib/lp/registry/browser/tests/sourcepackage-views.txt lib/lp/registry/browser/tests/test_packaging.py lib/lp/registry/stories/packaging/xx-distributionsourcepackage-packaging-concurrent-deletion.txt lib/lp/registry/stories/packaging/xx-distributionsourcepackage-packaging.txt lib/lp/registry/stories/packaging/xx-sourcepackage-packaging.txt lib/lp/registry/stories/product/xx-product-package-pages.txt lib/lp/registry/stories/productseries/xx-productseries-delete.txt lib/lp/soyuz/stories/soyuz/xx-distroseries-sources.txt Tests ----- ./bin/test -vvt '/packaging-views.txt|/sourcepackage-views.txt|/test_packaging.py|xx-distributionsourcepackage-packaging-concurrent-deletion.txt|xx-distributionsourcepackage-packaging.txt|xx-sourcepackage-packaging.txt|xx-product-package-pages.txt|xx-productseries-delete.txt|soyuz/xx-distroseries-sources.txt' Incremental diff ---------------- === modified file 'lib/canonical/launchpad/icing/style-3-0.css.in' --- lib/canonical/launchpad/icing/style-3-0.css.in 2010-02-17 00:43:19 +0000 +++ lib/canonical/launchpad/icing/style-3-0.css.in 2010-03-02 00:49:19 +0000 @@ -814,7 +814,7 @@ } input[type="submit"].icon-only { vertical-align: middle; - border: 0; + border: 0; padding: 0; height: 16px; width: 16px; === modified file 'lib/canonical/launchpad/templates/launchpad-form.pt' --- lib/canonical/launchpad/templates/launchpad-form.pt 2009-11-26 09:18:22 +0000 +++ lib/canonical/launchpad/templates/launchpad-form.pt 2010-03-02 04:07:05 +0000 @@ -16,6 +16,13 @@ accept-charset="UTF-8">
+ + This field is used by the ReturnToReferrerMixin. + +

This is the description of the form. === modified file 'lib/canonical/launchpad/webapp/launchpadform.py' --- lib/canonical/launchpad/webapp/launchpadform.py 2010-02-19 01:50:36 +0000 +++ lib/canonical/launchpad/webapp/launchpadform.py 2010-03-02 03:55:25 +0000 @@ -7,10 +7,11 @@ __metaclass__ = type __all__ = [ - 'LaunchpadFormView', - 'LaunchpadEditFormView', 'action', 'custom_widget', + 'LaunchpadEditFormView', + 'LaunchpadFormView', + 'ReturnToReferrerMixin', 'safe_action', ] @@ -32,7 +33,7 @@ IMultiLineWidgetLayout, ICheckBoxWidgetLayout, IAlwaysSubmittedWidget, UnsafeFormGetSubmissionError) from canonical.launchpad.webapp.menu import escape -from canonical.launchpad.webapp.publisher import LaunchpadView +from canonical.launchpad.webapp.publisher import canonical_url, LaunchpadView classImplements(CheckBoxWidget, ICheckBoxWidgetLayout) @@ -434,3 +435,30 @@ """ action.is_safe = True return action + + +class ReturnToReferrerMixin: + """Return to the previous page after submitting the form. + + The _return_url is stored in a hidden field in the launchpad-form.pt + between the request to view the form and submitting the form. + """ + + @property + def _return_url(self): + """See `LaunchpadFormView`.""" + # The referer header we want is only available before the view's + # form submits to itself. This field is a hidden input in the form. + referrer = self.request.form.get('_return_url') + if referrer is None: + # "referer" is misspelled in the HTTP specification. + referrer = self.request.getHeader('referer') + + if (referrer is not None + and referrer.startswith(self.request.getApplicationURL())): + return referrer + else: + return canonical_url(self.context) + + next_url = _return_url + cancel_url = _return_url === modified file 'lib/lp/registry/browser/configure.zcml' --- lib/lp/registry/browser/configure.zcml 2010-02-26 22:59:30 +0000 +++ lib/lp/registry/browser/configure.zcml 2010-03-02 19:33:41 +0000 @@ -1958,7 +1958,7 @@ permission="zope.Public" name="+upstream-connections" facet="overview" - class="lp.registry.browser.sourcepackage.SourcePackageAssociationPortletView" + class="lp.registry.browser.sourcepackage.SourcePackageUpstreamConnectionsView" template="../templates/sourcepackage-upstream-connections.pt"/>

-

- Schema validation errors. -

-

- Field specific error for the hidden packaging field. -

-
@@ -141,25 +126,14 @@ () -
+
-
- - - -
- - + +
=== modified file 'lib/lp/registry/templates/product-packages.pt' --- lib/lp/registry/templates/product-packages.pt 2010-01-11 20:58:42 +0000 +++ lib/lp/registry/templates/product-packages.pt 2010-03-03 13:59:12 +0000 @@ -40,16 +40,11 @@ Distribution series Source package Version -   +   - - + @@ -69,17 +64,11 @@ 2.3.4-1 - - - -
- - - - - + + + +
+ @@ -99,7 +88,7 @@

Packages by distribution

- +

Ubuntu Linux === modified file 'lib/lp/registry/templates/sourcepackage-remove-packaging.pt' --- lib/lp/registry/templates/sourcepackage-remove-packaging.pt 2010-02-26 21:20:02 +0000 +++ lib/lp/registry/templates/sourcepackage-remove-packaging.pt 2010-03-02 23:26:33 +0000 @@ -9,17 +9,23 @@
-
-
-

- Do you want to remove the upstream link to - ? -

-

- Links from distribution packages to upstream project series let - distribution and upstream maintainers share bugs, patches, and - translations efficiently. -

+
+ This upstream association was deleted already. +
+
=== modified file 'lib/lp/registry/templates/sourcepackage-upstream-connections.pt' --- lib/lp/registry/templates/sourcepackage-upstream-connections.pt 2010-02-26 23:35:06 +0000 +++ lib/lp/registry/templates/sourcepackage-upstream-connections.pt 2010-03-02 20:07:38 +0000 @@ -4,6 +4,10 @@ xmlns:i18n="http://xml.zope.org/namespaces/i18n" omit-tag=""> + + view.request.annotations['show_edit_buttons'] can be set in views + that include this page to display the edit and remove buttons. +