Merge lp:~sinzui/launchpad/list-urls-bug-463444 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Guilherme Salgado
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~sinzui/launchpad/list-urls-bug-463444
Merge into: lp:launchpad
Diff against target: 209 lines
2 files modified
lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt (+1/-1)
lib/canonical/launchpad/mailnotification.py (+33/-27)
To merge this branch: bzr merge lp:~sinzui/launchpad/list-urls-bug-463444
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) code Approve
Review via email: mp+14186@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

This is my branch to fix team join emails have bad mailing list url.

    lp:~sinzui/launchpad/list-urls-bug-463444
    Diff size: 35
    Launchpad bug: https://bugs.launchpad.net/bugs/463444
    Test command: ./bin/test -vv -t teammembership-email-notification
    Pre-implementation: no one
    Target release: 3.1.10

= Fix team join emails have bad mailing list url =

The URL provided for subscribing to team emails is a launchpad.dev email.

== Rules ==

emailtemplates/team-list-subscribe-block has the server hard coded
teammembership-email-notification.txt will always pass.

    * Change the email template to use a %(editemails_url)s
      * Watch the test fail.
    * Add code to interpolar "+editemails" % canonical_url(person)
      * Watch the test pass.

== QA ==

    * Open the staging mailbox and mark all email read.
    * Add someone to your team on staging.
    * Update the mailbox and read the email to the new member.
    * Verify that the email's edit URL is:
      https://staging.launchpad.net/people/+me/+editemails

== Lint ==

Linting changed files:
  lib/canonical/launchpad/mailnotification.py
  lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt

== Test ==

lp/registry/doc/teammembership-email-notification.txt did not change because
it was already testing for the correct result. The email template was
hard coded to always return the correct URL.

The test failed when the substitution variable was added. It passed after
a few trials make the URL from ILaunchpadRoot.

== Implementation ==

    * lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt
      * Replaced the hard coded URL with a substiution variable.
    * lib/canonical/launchpad/mailnotification.py
      * Updated the code to create a URL from ILaunchpadRoot and to
        interpolate that into the team-list-subscribe-block text.

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

This looks good, but you could use webapp.urlappend() to construct the URL to the +editemails page.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt'
2--- lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt 2009-08-24 03:53:19 +0000
3+++ lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt 2009-10-30 13:10:25 +0000
4@@ -1,4 +1,4 @@
5
6 If you would like to subscribe to the team list, use the link below
7 to update your Mailing List Subscription preferences.
8- <http://launchpad.dev/people/+me/+editemails>
9+ <%(editemails_url)s>
10
11=== modified file 'lib/canonical/launchpad/mailnotification.py'
12--- lib/canonical/launchpad/mailnotification.py 2009-08-24 03:53:19 +0000
13+++ lib/canonical/launchpad/mailnotification.py 2009-10-30 13:10:25 +0000
14@@ -36,6 +36,7 @@
15 IStructuralSubscriptionTarget, ITeamMembershipSet, IUpstreamBugTask,
16 TeamMembershipStatus)
17 from lp.bugs.interfaces.bugchange import IBugChange
18+from canonical.launchpad.interfaces.launchpad import ILaunchpadRoot
19 from canonical.launchpad.interfaces.message import (
20 IDirectEmailAuthorization, QuotaReachedError)
21 from canonical.launchpad.interfaces.structuralsubscription import (
22@@ -45,7 +46,8 @@
23 from lp.services.mail.mailwrapper import MailWrapper
24 from lp.services.mail.notificationrecipientset import (
25 NotificationRecipientSet)
26-from canonical.launchpad.webapp import canonical_url
27+from canonical.launchpad.webapp.publisher import canonical_url
28+from canonical.launchpad.webapp.url import urlappend
29
30
31 CC = "CC"
32@@ -74,6 +76,7 @@
33 IBug.getBugNotificationRecipients().
34 """
35 implements(INotificationRecipientSet)
36+
37 def __init__(self, duplicateof=None):
38 """Constructs a new BugNotificationRecipients instance.
39
40@@ -191,7 +194,7 @@
41
42 def format_rfc2822_date(date):
43 """Formats a date according to RFC2822's desires."""
44- return formatdate(rfc822.mktime_tz(date.utctimetuple() + (0,)))
45+ return formatdate(rfc822.mktime_tz(date.utctimetuple() + (0, )))
46
47
48 class BugNotificationBuilder:
49@@ -461,8 +464,7 @@
50 get_bugmail_error_address(), [config.launchpad.errors_address],
51 'Unhandled Email: %s' % file_alias_url,
52 template % {'url': file_alias_url, 'error_msg': message},
53- headers={'X-Launchpad-Unhandled-Email': message}
54- )
55+ headers={'X-Launchpad-Unhandled-Email': message})
56
57
58 def generate_bug_add_email(bug, new_recipients=False, reason=None,
59@@ -505,12 +507,12 @@
60
61 mailwrapper = MailWrapper(width=72)
62 content_substitutions = {
63- 'visibility' : visibility,
64- 'bug_url' : canonical_url(bug),
65+ 'visibility': visibility,
66+ 'bug_url': canonical_url(bug),
67 'bug_info': "\n".join(bug_info),
68 'bug_title': bug.title,
69 'description': mailwrapper.format(bug.description),
70- 'notification_rationale': reason
71+ 'notification_rationale': reason,
72 }
73
74 if new_recipients:
75@@ -571,13 +573,11 @@
76 # which begin with '?'.
77 text_diff = [
78 diff_line for diff_line in text_diff
79- if not diff_line.startswith('?')
80- ]
81+ if not diff_line.startswith('?')]
82 # Add a whitespace between the +/- and the text line.
83 text_diff = [
84 re.sub('^([\+\- ])(.*)', r'\1 \2', line)
85- for line in text_diff
86- ]
87+ for line in text_diff]
88 text_diff = '\n'.join(text_diff)
89 return text_diff
90
91@@ -585,9 +585,9 @@
92 def _get_task_change_row(label, oldval_display, newval_display):
93 """Return a row formatted for display in task change info."""
94 return u"%(label)13s: %(oldval)s => %(newval)s\n" % {
95- 'label' : label.capitalize(),
96- 'oldval' : oldval_display,
97- 'newval' : newval_display}
98+ 'label': label.capitalize(),
99+ 'oldval': oldval_display,
100+ 'newval': newval_display}
101
102
103 def _get_task_change_values(task_change, displayattrname):
104@@ -614,7 +614,7 @@
105 """
106 changes = {}
107
108- for field_name in ("title", "description", "name", "private",
109+ for field_name in ("title", "description", "name", "private",
110 "security_related", "duplicateof", "tags"):
111 # fields for which we show old => new when their values change
112 old_val = getattr(old_bug, field_name)
113@@ -786,7 +786,7 @@
114 bug=bug,
115 bugurl=canonical_url(bug),
116 user=IPerson(event.user),
117- attachment={'new' : bugattachment, 'old': None})
118+ attachment={'new': bugattachment, 'old': None})
119
120 add_bug_change_notifications(bug_delta)
121
122@@ -799,7 +799,7 @@
123 bug=bug,
124 bugurl=canonical_url(bug),
125 user=IPerson(event.user),
126- attachment={'old' : bugattachment, 'new': None})
127+ attachment={'old': bugattachment, 'new': None})
128
129 add_bug_change_notifications(bug_delta)
130
131@@ -908,8 +908,12 @@
132 "You received this email because you are the new member.")
133
134 if team.mailing_list is not None:
135- list_instructions = get_email_template(
136+ template = get_email_template(
137 'team-list-subscribe-block.txt')
138+ editemails_url = urlappend(
139+ canonical_url(getUtility(ILaunchpadRoot)),
140+ 'people/+me/+editemails')
141+ list_instructions = template % dict(editemails_url=editemails_url)
142 else:
143 list_instructions = ''
144
145@@ -990,6 +994,7 @@
146 """Format the email subject line for a specification."""
147 return '[Blueprint %s] %s' % (spec.name, spec.title)
148
149+
150 @block_implicit_flushes
151 def notify_specification_modified(spec, event):
152 """Notify the related people that a specification has been modifed."""
153@@ -1061,7 +1066,6 @@
154 simple_sendmail_from_person(user, address, subject, body)
155
156
157-
158 @block_implicit_flushes
159 def notify_specification_subscription_created(specsub, event):
160 """Notify a user that they have been subscribed to a blueprint."""
161@@ -1074,12 +1078,13 @@
162 'You are now subscribed to the blueprint '
163 '%(blueprint_name)s - %(blueprint_title)s.\n\n'
164 '--\n %(blueprint_url)s' %
165- {'blueprint_name' : spec.name,
166- 'blueprint_title' : spec.title,
167- 'blueprint_url' : canonical_url(spec)})
168+ {'blueprint_name': spec.name,
169+ 'blueprint_title': spec.title,
170+ 'blueprint_url': canonical_url(spec)})
171 for address in get_contact_email_addresses(person):
172 simple_sendmail_from_person(user, address, subject, body)
173
174+
175 @block_implicit_flushes
176 def notify_specification_subscription_modified(specsub, event):
177 """Notify a subscriber to a blueprint that their
178@@ -1103,10 +1108,10 @@
179 '%(blueprint_name)s - %(blueprint_title)s '
180 'has changed to [%(specsub_type)s].\n\n'
181 '--\n %(blueprint_url)s' %
182- {'blueprint_name' : spec.name,
183- 'blueprint_title' : spec.title,
184- 'specsub_type' : specsub_type,
185- 'blueprint_url' : canonical_url(spec)})
186+ {'blueprint_name': spec.name,
187+ 'blueprint_title': spec.title,
188+ 'specsub_type': specsub_type,
189+ 'blueprint_url': canonical_url(spec)})
190 for address in get_contact_email_addresses(person):
191 simple_sendmail_from_person(user, address, subject, body)
192
193@@ -1184,6 +1189,7 @@
194 template % replacements, force_wrap=True)
195 simple_sendmail(from_address, address, subject, body)
196
197+
198 @block_implicit_flushes
199 def notify_new_ppa_subscription(subscription, event):
200 """Notification that a new PPA subscription can be activated."""
201@@ -1290,7 +1296,7 @@
202 u'',
203 u'-- ',
204 u'This message was sent from Launchpad by the user',
205- u'%s (%s)' % (sender_name , canonical_url(sender)),
206+ u'%s (%s)' % (sender_name, canonical_url(sender)),
207 u'using %s.',
208 u'For more information see',
209 u'https://help.launchpad.net/YourAccount/ContactingPeople',