Merge lp://staging/~sinzui/launchpad/announcement-edits into lp://staging/launchpad

Proposed by Curtis Hovey
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~sinzui/launchpad/announcement-edits
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~sinzui/launchpad/announcement-edits
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) Approve
Review via email: mp+9519@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :
Download full text (3.7 KiB)

This is my branch to update announcement modification pages to UI 3.0.

Note that this branch depends upon
lp:~sinzui/launchpad/base-layout-bug-407052
which is approved, but not landed yet. That branch provides the base
layout,
navigation menu, and form changes for to support the 3.0 UI for edit
pages.

    lp:~sinzui/launchpad/announcement-edits
    Diff size: 293
    Launchpad bug: https://bugs.launchpad.net/bugs/407416
    Test command: ./bin/test -vvt "stories/announcement"
    Pre-implementation: beuno
    Target release: 2.2.8

= Update announcement modification pages to UI 3.0 =

This work was split from bug #399010 Update simple edit pages to
base-layout
because the effort was too large to do in one branch.

This branch implicitly fixes
Bug #297877 Announcement/+{retarget,delete,retract,publish} don't say on
    which announcement they will operate

because base-layout provides the context.title as a <h1> if it was not
provided. This behaviour fixes a lot of forms.

== Rules ==

* Switch the pages to use the main_only layout
* Replace the context menu with a navigation menu displayed as related
  links list.

== QA ==

Visit edge or staging.
    * Visit
https://edge.launchpad.net/launchpad-project/+announcement/3086
    * Choose Modify announcement.
      * Verify the announcements title is shown, "Launchpad 2.2.6
released" as
        the <h1>
      * Verify there is a list of links to the other modification pages
below
        the form.
    * Choose Retract announcement.
      * Verify the announcements title is shown, "Launchpad 2.2.6
released"
        as the <h1>
      * Verify there is a list of links to the other modification pages
below
        the form.
    * Choose Move announcement.
      * Verify the announcements title is shown, "Launchpad 2.2.6
released"
        as the <h1>
      * Verify there is a list of links to the other modification pages
below
        the form.
    * Choose Delete announcement.
      * Verify the announcements title is shown, "Launchpad 2.2.6
released" as
        the <h1>
      * Verify there is a list of links to the other modification pages
below
        the form.

== Lint ==

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/registry/browser/announcement.py
  lib/lp/registry/browser/configure.zcml
  lib/lp/registry/stories/announcements/xx-announcements.txt
  lib/lp/registry/templates/announcement-delete.pt
  lib/lp/registry/templates/announcement-edit.pt
  lib/lp/registry/templates/announcement-retarget.pt
  lib/lp/registry/templates/announcement-retract.pt

== Test ==

    * lib/lp/registry/stories/announcements/xx-announcements.txt
      * Updated the test because I changed the wording of the Move
        announcement link to be consistent with other links

== Implementation ==

    * lib/lp/registry/browser/announcement.py
      * refactored the context menu to use a mixin. Used the same mixin
        to create a navigation menu that will generate the list of
related
        pages
    * lib/lp/registry/browser/configure.zcml
      * Registered the new navigation menu.
 ...

Read more...

Revision history for this message
Guilherme Salgado (salgado) wrote :

Hi Curtis,

I'm happy with your changes.

 review approve
>
--
Guilherme Salgado <email address hidden>

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/announcement.py'
2--- lib/lp/registry/browser/announcement.py 2009-07-17 00:26:05 +0000
3+++ lib/lp/registry/browser/announcement.py 2009-07-31 15:48:22 +0000
4@@ -17,7 +17,7 @@
5 'HasAnnouncementsView',
6 ]
7
8-from zope.interface import Interface
9+from zope.interface import implements, Interface
10
11 from zope.schema import Choice, TextLine
12
13@@ -37,14 +37,12 @@
14 AnnouncementsFeedLink, FeedsMixin, RootAnnouncementsFeedLink)
15 from canonical.launchpad.webapp.authorization import check_permission
16 from canonical.launchpad.webapp.batching import BatchNavigator
17-
18+from canonical.launchpad.webapp.menu import NavigationMenu
19 from canonical.widgets import AnnouncementDateWidget
20
21
22-class AnnouncementContextMenu(ContextMenu):
23-
24- usedfor = IAnnouncement
25- links = ['edit', 'retarget', 'retract']
26+class AnnouncementMenuMixin:
27+ """A mixin of links common to many menus."""
28
29 @enabled_with_permission('launchpad.Edit')
30 def edit(self):
31@@ -53,13 +51,37 @@
32
33 @enabled_with_permission('launchpad.Edit')
34 def retarget(self):
35- text = 'Move to another project'
36+ text = 'Move announcement'
37 return Link('+retarget', text, icon='edit')
38
39 @enabled_with_permission('launchpad.Edit')
40 def retract(self):
41 text = 'Retract announcement'
42- return Link('+retract', text, icon='edit')
43+ return Link('+retract', text, icon='remove')
44+
45+ @enabled_with_permission('launchpad.Edit')
46+ def delete(self):
47+ text = 'Delete announcement'
48+ return Link('+delete', text, icon='trash-icon')
49+
50+
51+class AnnouncementContextMenu(ContextMenu, AnnouncementMenuMixin):
52+
53+ usedfor = IAnnouncement
54+ links = ['edit', 'retarget', 'retract', 'delete']
55+
56+
57+class IAnnouncemenEditMenu(Interface):
58+ """A marker interface for modify announcement navigation menu."""
59+
60+
61+class AnnouncementEditNavigationMenu(NavigationMenu, AnnouncementMenuMixin):
62+ """A sub-menu for different aspects of modifying an announcement."""
63+
64+ usedfor = IAnnouncemenEditMenu
65+ facet = 'overview'
66+ title = 'Change announcement'
67+ links = ('edit', 'retarget', 'retract', 'delete')
68
69
70 class AnnouncementFormMixin:
71@@ -114,6 +136,8 @@
72 class AnnouncementEditView(AnnouncementFormMixin, LaunchpadFormView):
73 """A view which allows you to edit the announcement."""
74
75+ implements(IAnnouncemenEditMenu)
76+
77 schema = AddAnnouncementForm
78 field_names = ['title', 'summary', 'url', ]
79 label = _('Modify this announcement')
80@@ -145,6 +169,8 @@
81
82 class AnnouncementRetargetView(AnnouncementFormMixin, LaunchpadFormView):
83
84+ implements(IAnnouncemenEditMenu)
85+
86 schema = AnnouncementRetargetForm
87 field_names = ['target']
88 label = _('Move this announcement to a different project')
89@@ -194,6 +220,8 @@
90
91 class AnnouncementRetractView(AnnouncementFormMixin, LaunchpadFormView):
92
93+ implements(IAnnouncemenEditMenu)
94+
95 schema = IAnnouncement
96 label = _('Retract this announcement')
97
98@@ -205,6 +233,8 @@
99
100 class AnnouncementDeleteView(AnnouncementFormMixin, LaunchpadFormView):
101
102+ implements(IAnnouncemenEditMenu)
103+
104 schema = IAnnouncement
105 label = _('Delete this announcement')
106
107
108=== modified file 'lib/lp/registry/browser/configure.zcml'
109--- lib/lp/registry/browser/configure.zcml 2009-07-23 21:38:32 +0000
110+++ lib/lp/registry/browser/configure.zcml 2009-07-31 15:49:18 +0000
111@@ -771,7 +771,7 @@
112 template="../templates/announcements-all.pt"/>
113 <browser:menus
114 classes="
115- AnnouncementContextMenu"
116+ AnnouncementContextMenu AnnouncementEditNavigationMenu"
117 module="lp.registry.browser.announcement"/>
118 <facet
119 facet="overview">
120
121=== modified file 'lib/lp/registry/stories/announcements/xx-announcements.txt'
122--- lib/lp/registry/stories/announcements/xx-announcements.txt 2009-06-12 16:36:02 +0000
123+++ lib/lp/registry/stories/announcements/xx-announcements.txt 2009-07-31 15:51:14 +0000
124@@ -555,7 +555,7 @@
125
126 >>> priv_browser.open('http://launchpad.dev/kubuntu/+announcements')
127 >>> priv_browser.getLink(edit_link_text).click()
128- >>> priv_browser.getLink('move this announcement').click()
129+ >>> priv_browser.getLink('Move announcement').click()
130 >>> print priv_browser.url
131 http://launchpad.dev/kubuntu/+announcement/.../+retarget
132 >>> priv_browser.getControl('For').value = 'guadalinex'
133@@ -572,7 +572,7 @@
134 ... setupBrowser(auth="Basic colin.watson@ubuntulinux.com:test")
135 >>> kamion_browser.open('http://launchpad.dev/guadalinex/+announcements')
136 >>> kamion_browser.getLink(edit_link_text).click()
137- >>> kamion_browser.getLink('move this announcement').click()
138+ >>> kamion_browser.getLink('Move announcement').click()
139 >>> print kamion_browser.url
140 http://launchpad.dev/guadalinex/+announcement/.../+retarget
141 >>> kamion_browser.getControl('For').value = 'kubuntu'
142
143=== modified file 'lib/lp/registry/templates/announcement-delete.pt'
144--- lib/lp/registry/templates/announcement-delete.pt 2009-07-17 17:59:07 +0000
145+++ lib/lp/registry/templates/announcement-delete.pt 2009-07-31 15:51:47 +0000
146@@ -3,20 +3,15 @@
147 xmlns:tal="http://xml.zope.org/namespaces/tal"
148 xmlns:metal="http://xml.zope.org/namespaces/metal"
149 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
150- xml:lang="en"
151- lang="en"
152- dir="ltr"
153- metal:use-macro="context/@@main_template/master"
154+ metal:use-macro="view/macro:page/main_only"
155 i18n:domain="launchpad"
156 >
157
158 <body>
159
160-<metal:portlets fill-slot="portlets">
161-</metal:portlets>
162-
163 <div metal:fill-slot="main">
164
165+ <div class="top-portlet">
166 <div metal:use-macro="context/@@launchpad_form/form">
167
168 <p metal:fill-slot="extra_info" class="documentDescription">
169@@ -26,7 +21,9 @@
170 </p>
171
172 </div>
173+ </div>
174
175+ <tal:menu replace="structure view/@@+related-pages" />
176 </div>
177
178 </body>
179
180=== modified file 'lib/lp/registry/templates/announcement-edit.pt'
181--- lib/lp/registry/templates/announcement-edit.pt 2009-07-17 17:59:07 +0000
182+++ lib/lp/registry/templates/announcement-edit.pt 2009-07-31 15:52:00 +0000
183@@ -3,10 +3,7 @@
184 xmlns:tal="http://xml.zope.org/namespaces/tal"
185 xmlns:metal="http://xml.zope.org/namespaces/metal"
186 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
187- xml:lang="en"
188- lang="en"
189- dir="ltr"
190- metal:use-macro="context/@@main_template/master"
191+ metal:use-macro="view/macro:page/main_only"
192 i18n:domain="launchpad"
193 >
194
195@@ -16,18 +13,12 @@
196 use-macro="context/@@launchpad_widget_macros/yui2calendar-dependencies" />
197 </metal:block>
198
199-<metal:portlets fill-slot="portlets">
200-</metal:portlets>
201-
202 <div metal:fill-slot="main">
203-
204- <div metal:use-macro="context/@@launchpad_form/form" />
205-
206- <p>
207- You can also <a href="+retarget">move this announcement to a different
208- project</a>.
209- </p>
210-
211+ <div class="top-portlet">
212+ <div metal:use-macro="context/@@launchpad_form/form" />
213+ </div>
214+
215+ <tal:menu replace="structure view/@@+related-pages" />
216 </div>
217
218 </body>
219
220=== modified file 'lib/lp/registry/templates/announcement-retarget.pt'
221--- lib/lp/registry/templates/announcement-retarget.pt 2009-07-17 17:59:07 +0000
222+++ lib/lp/registry/templates/announcement-retarget.pt 2009-07-31 15:52:17 +0000
223@@ -3,20 +3,15 @@
224 xmlns:tal="http://xml.zope.org/namespaces/tal"
225 xmlns:metal="http://xml.zope.org/namespaces/metal"
226 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
227- xml:lang="en"
228- lang="en"
229- dir="ltr"
230- metal:use-macro="context/@@main_template/master"
231+ metal:use-macro="view/macro:page/main_only"
232 i18n:domain="launchpad"
233 >
234
235 <body>
236
237-<metal:portlets fill-slot="portlets">
238-</metal:portlets>
239-
240 <div metal:fill-slot="main">
241
242+ <div class="top-portlet">
243 <div metal:use-macro="context/@@launchpad_form/form">
244
245 <p metal:fill-slot="extra_info" class="documentDescription">
246@@ -25,7 +20,9 @@
247 </p>
248
249 </div>
250+ </div>
251
252+ <tal:menu replace="structure view/@@+related-pages" />
253 </div>
254
255 </body>
256
257=== modified file 'lib/lp/registry/templates/announcement-retract.pt'
258--- lib/lp/registry/templates/announcement-retract.pt 2009-07-17 17:59:07 +0000
259+++ lib/lp/registry/templates/announcement-retract.pt 2009-07-31 15:52:41 +0000
260@@ -3,20 +3,15 @@
261 xmlns:tal="http://xml.zope.org/namespaces/tal"
262 xmlns:metal="http://xml.zope.org/namespaces/metal"
263 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
264- xml:lang="en"
265- lang="en"
266- dir="ltr"
267- metal:use-macro="context/@@main_template/master"
268+ metal:use-macro="view/macro:page/main_only"
269 i18n:domain="launchpad"
270 >
271
272 <body>
273
274-<metal:portlets fill-slot="portlets">
275-</metal:portlets>
276-
277 <div metal:fill-slot="main">
278
279+ <div class="top-portlet">
280 <div metal:use-macro="context/@@launchpad_form/form">
281
282 <p metal:fill-slot="extra_info" class="documentDescription">
283@@ -28,7 +23,9 @@
284 </p>
285
286 </div>
287+ </div>
288
289+ <tal:menu replace="structure view/@@+related-pages" />
290 </div>
291
292 </body>
293